112

I am new to dockers. When I am running the docker pull sonarqube I am getting the following error.

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

Can you please let me know why I am getting the error and how can I rectify this.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
rohit
  • 1,329
  • 2
  • 8
  • 10
  • 2
    `192.168.0.0/16` is reserved, local IP space and https://registry-1.docker.io should not be pointing to it; what happens when you ping `registry-1.docker.io` ? – TJ Biddle Nov 30 '17 at 18:49
  • 1
    I would suggest you to change DNS to 8.8.8.8. But it may not solve the problem in some cases. – Fony Lew Feb 16 '18 at 04:16
  • 1
    Proxy was the issue in my case – sathish kumar May 27 '19 at 08:47
  • I tried a few times the same command and it worked eventually. I did nothing. It's like the host has limited slots to serve and I had to be lucky or something. – LovaBill Nov 15 '21 at 11:38
  • the Given IP implements that you are inside a Virtualmachine, I think the Problem is really that you have no Internet Connection. Check your Networkports for the VM, you need a NAT Port to be connected to the Internet. All given Answers are right actually but I guess this case Is realy about a missing Port – SamPhoenix Mar 24 '22 at 08:03

27 Answers27

113

I had similar issue on Ubuntu 16.04 and manage to solve it by adding more nameservers

You can try too.

  1. Open config file sudo nano /etc/resolv.conf and add the following under existing nameservers

    nameserver 8.8.8.8

    nameserver 8.8.4.4

  2. run following commands to restart daemon and docker service

    sudo systemctl daemon-reload

    sudo systemctl restart docker

Now try to pull image you want docker pull sonarqube

lev09
  • 2,020
  • 1
  • 15
  • 16
36

In my case on a Mac, only a restart of the docker-machine did the work:

docker-machine restart

Uninstalling docker did not work! Just the above restart is enough!

cyberPrivacy
  • 907
  • 10
  • 19
36

I was able to resolve by running the below command.

sudo systemctl restart docker
Tomer Shetah
  • 8,413
  • 7
  • 27
  • 35
Jagadeeswar
  • 537
  • 1
  • 7
  • 9
14
sudo vi /etc/resolv.conf

And change nameserver to 8.8.8.8

Antoine Thiry
  • 2,362
  • 4
  • 28
  • 42
Nitin
  • 541
  • 4
  • 5
10

I had the same issue, for me I was behind my office proxy and docker was not picking up the proxy set for terminal. To fix this, i have to set the proxy in docker settings window, which can be accessed from

task bar -> docker -> settings enter image description here

vikash vik
  • 686
  • 5
  • 10
9

I was able to solve this issue, by logging into docker.

sudo docker login
Enter your login credentials 
sudo docker pull 'yourImageName'

Aishwarya Patil
  • 447
  • 5
  • 9
5

in windows, just restart the docker, it worked for me. Go to Docker Desktop dashboard, click on the icon with setting icon and click restart

Tushar Seth
  • 563
  • 7
  • 15
4

You need to add to your /etc/hosts in terminal write

$ sudo nano /etc/hosts

add below line and save it, try to run command and it will be working

34.228.211.243  registry-1.docker.io
Shajed
  • 647
  • 10
  • 14
4

I just restarted and it works fine again!

Micael Mota
  • 433
  • 3
  • 7
4

This could also be a DNS issue. Altering your nameservers will most likely resolve it, if is indeed related to your DNS.

You can verify the issue with: curl -vvv https://registry-1.docker.io/v2/ for a more detailed path.

If you are on ubuntu 18.04 or higher /etc/resolve.conf won't do the trick, they moved network management to NetPlan configs.

Add the google nameservers to your configuration (8.8.8.8 and 8.8.4.4)

find your network adapter name with ip a

network:
  version: 2
  renderer: NetworkManager
  ethernets:
      [network adapter name]:
              addresses: ...
              gateway4: ...
              nameservers:
                      addresses:
                              - 8.8.8.8
                              - 8.8.4.4
                      search: []

And run sudo netplan apply

Dennis Van Bets
  • 111
  • 1
  • 2
  • 8
4

Disable experiment features and try again does the trick. Otherwise add the config below to daemon.json

"dns": [
    "8.8.8.8",
    "8.8.4.4"
  ]
ZenithS
  • 987
  • 8
  • 20
  • This response lacks the full file path, structure, and info about having to restart the docker service afterward. So, go to `/etc/docker/daemon.json`, edit the file with admin privileges, add this entry, remember about surrounding braces `{}` since it's a json file, save and then run `sudo systemctl restart docker` – Yourin Mar 04 '22 at 19:30
3

If your machine are located within the Great China area or using related Virtual Server, add Registry Mirrors to help your bypass the complex network router.

Or your can set a http_proxy for your docker configuration, referencing this link: https://docs.docker.com/config/daemon/systemd/#httphttps-proxy

Diya Li
  • 1,048
  • 9
  • 21
3

make sure that your server is not located in the following areas:

Docker is a US company, we must comply with US export control regulations. In an effort to comply with these, we now block all IP addresses that are located in Cuba, Iran, North Korea, Republic of Crimea, Sudan, and Syria.

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Ali_Hr
  • 4,017
  • 3
  • 27
  • 34
2

Things that might work:

  1. Check your proxy settings
  2. Restart docker
  3. Go to your docker settings and check if you're signed in to docker hub, if you aren't, sign in and try again (This worked for me)
OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
Mehr Heer
  • 31
  • 4
2

It happens when you are not logged in too, it happened to me. Problem gone after I logged in

Abdullah Ahçı
  • 786
  • 10
  • 19
1

A restart of your internet connection might solve this.

  • 1
    Don't know why it got a downvote. In my case, I got this error when the internet connection was disconnected. Worked fine, after reconnecting. Error response from daemon: Get "https://registry-1.docker.io/v2/": dial tcp: lookup registry-1.docker.io on ***.***.**.*:**: no such host – ahairshi Feb 07 '22 at 06:42
0

In China, Add 114.114.114.114 to resolv.conf fixed it. sudo echo "nameserver 114.114.114.114" >> /etc/resolv.conf

Contropist
  • 401
  • 4
  • 9
0

Had same issue, I restarted docker and it worked

Martin Karari
  • 180
  • 2
  • 9
0

I got the same error & I solved it by executing the below-mentioned commands, If you are working on the windows version, you can try these commands Steps to be followed : Open the command prompt & execute these commands,

set http_proxy="http://user:pwd@proxyurl.com:port"

set https_proxy="https://user:pwd@proxy-url.com:port"
dev_user
  • 417
  • 1
  • 3
  • 16
0

My issue was tha ti was behind a corporate proxy and hence i was unable to reach the registry-1.docker.io.

Solution:

I bypassed this URL registry-1.docker.io in the proxy server for following

  1. SSL bypass
  2. Authentication Bypass.

Then i configured the proxy settings in docker.service file in RHEL server as

Environment="HTTP_PROXY=http://proxy.example.com:80"
Environment="HTTPS_PROXY=http://proxy.example.com:443"
NO_PROXY=“tnd-harbor.india.airtel.itm,10.241.99.232,
registry-1.docker.io/v2/”

Make sure the HTTPS_PROXY protocol is http.

By doing this i was able to fetch images.

Shikhar Chaudhary
  • 425
  • 1
  • 6
  • 11
0

After trying most solutions mentioned on this page nothing worked for me. Weirdly mine worked after updating docker desktop from some 4.16.x to 4.17.1 That update restarted docker and might've fixed whatever the issue was. Hope it helps someone.

Hari
  • 219
  • 4
  • 8
0

For me the issue was due to eval $(minikube docker-env) in my terminal .bash_profile/.profile

When this runs it sets

export DOCKER_HOST="tcp://192.168.64.4:2376"

To fix I ran

unset DOCKER_HOST

I also removed eval $(minikube docker-env) from my shell env.

Jason Heithoff
  • 508
  • 3
  • 10
0

I had this issue and tried so many solutions like restarting-docker, setting buildkit to false in docker-Engine setting tab (Docker Windows), etc, all to no avail. When I viewed my containers and images in Docker-window, the list were empty.

I re-installed docker and everything was fine.

0

In My case the issue was resolved by changing the DNS settings Wi-Fi network.

By modifying the DNS server to 8.8.8.8 (Google Public DNS) from 192.168.1.1 it worked

DNS change in MAC

Santosh Joshi
  • 3,290
  • 5
  • 36
  • 49
-1

I was getting the same error. Tried a few things like restarting the server, checking configuration etc... Finally, it got resolved by adding proxies (since I was using it inside my organization network)

ShailendraChoudhary
  • 143
  • 1
  • 3
  • 10
-1

I had the same problem, for me it was ACR repository name that I have misspelled. Maybe check your variables. I used it within Github Actions in the secret sections.

Marc Ottenbacher
  • 144
  • 2
  • 13
-1

I had this same issue with a different solution. The issue was that the internet wasn't connected. That's another thing to check if none of these fix it for you!