[SOLVED] Dial TCP lookup registry-1.docker.io temporary failure in name resolution Error

Dial TCP lookup registry-1.docker.io temporary failure in name resolution Error [SOLVED]

Docker service is running. I am trying to run a docker run hello-world, and it is showing a strange error message – temporary name resolution error

Dial TCP lookup registry-1.docker.io temporary failure in name resolution Error
Solving docker name resolution error

Docker name resolution Error

After a few hours, the problem is with name resolution from the OS itself.

# docker run hello-world
Trying to pull repository docker.io/library/hello-world ...
/usr/bin/docker-current: Get https://registry-1.docker.io/v2/:
 dial tcp: lookup registry-1.docker.io on 192.168.1.1:
 read udp 192.168.5.1:52213->192.168.1.1:53: i/o timeout.
See '/usr/bin/docker-current run --help'.
Solution: Add a working DNS IP address to resolv.conf

Solution for Docker name resolution Error:

The Docker daemon tells us it cannot reach the Docker registry. We can check whether the internet and DNS service is available. I found my default DNS entry could not provide DNS service (by simply doing a test ping google.com ).

The problem was solved by adding DNS entries 8.8.8.8 and 8.8.4.4 (DNS service IP addresses from Google) to the resolv.conf file:

# cat /etc/resolv.conf
nameserver 8.8.4.4
nameserver 8.8.8.8

Related articles: How to set DNS servers to Google DNS or Cloudflare DNS

Verifying docker run

Let us try running a Hello World again

# docker run hello-world
Unable to find image 'hello-world:latest' locally
Trying to pull repository docker.io/library/hello-world ...
latest: Pulling from docker.io/library/hello-world
1b392d010123: Pull complete
Digest: sha256:451ce111d12222c5df2a32c85e5a03d52cbcef6ac3586dd03075f3034f99dbca
Status: Downloaded newer image for docker.io/hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/

For more examples and ideas, visit:
https://docs.docker.com/get-started/

My system is CentOS 7, which should also work in RHEL or in Ubuntu.

# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)

Updated: Another possible cause of this error

Another possibility of this network error is the network blocking caused by your company firewall or the VPN. , You could try disconnecting (after you obtain permission from your company to do so!) from the VPN and rerunning the docker command.