×

Cannot download Docker images behind a proxy - Fix it Now


Cannot download Docker images behind a proxy - Fix it Now

Sometimes Docker users are unable to download Docker images behind a proxy due to issues with the Docker proxy settings.

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to resolve such Docker-related issues while troubleshooting Docker issues.

In this context, we shall look into method to fix this Docker error.


What to do when we Cannot download Docker images behind a proxy ?

We had a customer who installed Docker on his Ubuntu server. Then he tried running the below command:

$ sudo docker pull busybox

As a result, he received the below error:

Pulling repository busybox
2021/03/16 09:37:07 Get https://index.docker.io/v1/repositories/busybox/images: dial tcp: lookup index.docker.io on 127.0.1.1:53: no answer from server

In order to resolve this problem, we first create a systemd drop-in directory for the Docker service by running the below command.

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

Next, we create a file called /etc/systemd/system/docker.service.d/http-proxy.conf that adds the HTTP_PROXY environment variable:

[Service]
Environment="HTTP_PROXY=http://proxy.example.com:80/"

Note: In case, if you have internal Docker registries that you need to contact without proxying you can specify them via the NO_PROXY environment variable:

Environment="HTTP_PROXY=http://proxy.example.com:80/"
Environment="NO_PROXY=localhost,127.0.0.0/8,docker-registry.somecorporation.com"

After that, we flush the changes by running the below command:

$ sudo systemctl daemon-reload

Then we verify if the configuration is loaded or not. For that, we run the below command:

$ sudo systemctl show --property Environment docker
Environment=HTTP_PROXY=http://proxy.example.com:80/

Finally, we restart the Docker by running the below command:

$ sudo systemctl restart docker

Finally, this fixed the Docker error.


[Need urgent assistance in fixing Docker errors? – We're available 24*7. ]

Who We Are ?

Most prominent, efficient, and well-performing IT companies and software solutions.

Related Posts