How to use local proxy settings in docker-compose

I did a bit more research and seem to have used better key words because I have found my solution now. I wanted to share the solution with everyone, in case someone else may ever need it.

  • Create a folder for configuring the Docker service through systemd

    mkdir /etc/systemd/system/docker.service.d

  • Create a service configuration file at /etc/systemd/system/docker.service.d/http-proxy.conf and put the following in the newly created file

[Service]
 # NO_PROXY is optional and can be removed if not needed
 # Change proxy_url to your proxy IP or FQDN and proxy_port to your proxy port
 # For Proxy servers that require username and password authentication, just add the proper username and password to the URL. (see example below)

 # Example without authentication
 Environment="HTTP_PROXY=http://proxy_url:proxy_port" "NO_PROXY=localhost,127.0.0.0/8"

 # Example with authentication
 Environment="HTTP_PROXY=http://username:password@proxy_url:proxy_port" "NO_PROXY=localhost,127.0.0.0/8"

 # Example for SOCKS5

Environment="HTTP_PROXY=socks5://proxy_url:proxy_port" "NO_PROXY=localhost,127.0.0.0/8"
  • Reload systemctl so that new settings are read

    sudo systemctl daemon-reload

  • Verify that docker service Environment is properly set

    sudo systemctl show docker --property Environment

  • Restart docker service so that it uses updated Environment settings

    sudo systemctl restart docker

Now you can execute the docker-compose command on your machine without getting any connection refused error messages.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)