docker tutorials

docker: Error response from daemon: Get https://registry-1.docker.io/v2/: dial tcp: lookup registry-1.docker.io: no such host

This tutorial guides you on how to resolve docker: Error response from daemon: Get https://registry-1.docker.io/v2/: dial tcp: lookup registry-1.docker.io: no such host while running docker run command to find and pull the image from docker hub.

docker: Error response from daemon: Get https://registry-1.docker.io/v2/: dial tcp: lookup registry-1.docker.io: no such host.

I had setup docker in the ubuntu vm and tried to pull guacamole/guacd image to run as docker container. But it resulted in the following error.

$ sudo docker run --name guacd -d guacamole/guacd
Unable to find image 'guacamole/guacd:latest' locally
docker: Error response from daemon: Get https://registry-1.docker.io/v2/: dial tcp: lookup registry-1.docker.io: no such host.
See 'docker run --help'.

Solution – Setup Docker Proxy

I figured out that, since the docker is setup on development vm which is behind the corporate firewall it is not able to reach host registry-1.docker.io . Therefore, to fix the above docker error follow the below steps to setup Docker Proxy.

1: First, create a new directory called docker.service.d under /etc/systemd/system folder.

2: Next, create a new docker service configuration file under /etc/systemd/system/docker.service.d directory called http-proxy.conf.

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

$ touch http-proxy.conf

$ sudo nano http-proxy.conf

3: Add the following contents matching your environment.

[Service]
Environment="HTTP_PROXY=http://proxy.hostname:80/"
Environment="HTTPS_PROXY=http://proxy.hostname:80/"
Environment="NO_PROXY="localhost,127.0.0.1,::1"

After adding contents save and exit the text editor.

4: In order to flush the changes, you need to reload the daemon configuration.

$ sudo systemctl daemon-reload

5: Finally restart  Docker to apply the changes.

$ sudo systemctl restart docker

6: To check the docker service status you can run the following command.

$ sudo systemctl status docker

Check Docker Proxy Status

In order to check whether Docker Proxy is setup correctly you can verify using the following command.

$ sudo docker info

The above command displays system wide information regarding the Docker installation. Information displayed includes the kernel version, number of containers and images etc.,. It also prints the following information using which you can verify the docker proxy setup.

---
---
HTTP Proxy: http://proxy.hostname:80/
HTTPS Proxy: http://proxy.hostname:80/
No Proxy: localhost,127.0.0.1,::1
---
---

That’s it. Now you should be able to pull any image from the docker hub after restarting docker daemon and docker service. And you won’t see docker: Error response from daemon: Get https://registry-1.docker.io/v2/: dial tcp : lookup registry-1.docker.io any more.

Hope this article is helpful 🙂

References

Subscribe
Notify of
guest

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Robert Bosch
Robert Bosch
1 year ago

Saved my day. Thank you very much !!!!