Using Docker Behind a Corporate Proxy

As I was trying to pull docker image from hub.docker.com, it was showing me errors like below

error-response-from-daemon-get-https-registry-1-docker-io-v2

This ERROR occurs because of connection issues. If the system is behind a proxy then it’s more likely to run into this sort of error. This is how I have solved the PROXY issue for an UBUNTU based system which is using HTTP and HTTPS proxy. First, I have created a directory in /etc/systemd/system/ called docker.service.d. Then a file called http-proxy.conf in that directory.

Finally, I have populated the file with proxy information as shown below

[Service]
Environment="HTTP_PROXY=http://proxy.example.com:801234/" "NO_PROXY=localhost,127.0.0.1,docker-registry.organization.com"

If you are using HTTPS_PROXY, please change to HTTPS instead of HTTP in the above example.

Now, reload the systemd daemon with

sudo systemctl daemon-reload

Restart the docker service/engine

sudo systemctl restart docker

If everything is okay, the docker is now ready to use the proxy. You can verify docker environment variables by using the following command

sudo systemctl show --property=Environment docker

For more information for configuring proxy with docker visit docker official site documentation

Enjoy!