129

I am new to docker. When I am running 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.

6
  • 2
    192.168.0.0/16 is reserved, local IP space and registry-1.docker.io should not be pointing to it; what happens when you ping registry-1.docker.io ?
    – TJ Biddle
    Commented Nov 30, 2017 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
    Commented Feb 16, 2018 at 4:16
  • 2
    Proxy was the issue in my case Commented May 27, 2019 at 8: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
    Commented Nov 15, 2021 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
    Commented Mar 24, 2022 at 8:03

29 Answers 29

129

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

3
  • Consider this as the correct answer. Solved only with this.
    – Magno C
    Commented Sep 2, 2019 at 22:01
  • 1
    simply following step 2 worked for me
    – MoralCode
    Commented Apr 23, 2022 at 18:10
  • Adding 8.8.8.8 as one of the nameservers fixed the issue
    – Rafay
    Commented Nov 30, 2023 at 16:32
38

I was able to resolve by running the below command.

sudo systemctl restart docker
1
  • In Windows 10 restarting Docker through the GUI was enough; I didn't need to run any command through the WSL2 terminal Commented Apr 21, 2023 at 12:01
35

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!

3
  • 2
    This worked for me as well using windows docker toolbox
    – AndraeRay
    Commented Dec 13, 2019 at 8:24
  • 1
    Same here. Just restart fixed my issue
    – Jim C
    Commented Mar 3, 2020 at 19:21
  • Docker machine shouldn't really be used anymore Commented Dec 31, 2022 at 16:03
16
sudo vi /etc/resolv.conf

And change nameserver to 8.8.8.8

0
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

1
  • Same for me. And additionally, enable the used distro in Settings > Resources > WSL integration > Enable integration with additional distros Commented Aug 1 at 7:00
9

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

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

1
  • 2
    How would this fix network resolution issue? Commented Dec 31, 2022 at 16:04
5

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
1
  • 1
    Works for me. The current IP can be checked with dig registry-1.docker.io +short, atm is 54.236.113.205
    – frank_108
    Commented May 9 at 8:17
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

0
5

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

2
  • how can I find exactly the file to be modified?
    – Lore
    Commented Apr 29 at 12:07
  • This can differ between each version/release of an operation system. Best to google something like: "Change your DNS servers settings for {operating system}". The essence of the solution is adding "8.8.8.8" and "8.8.4.4" to your nameservers Commented Apr 30 at 18:48
4

I just restarted and it works fine again!

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"
  ]
1
  • 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
    Commented Mar 4, 2022 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

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.

1
  • 1
    Please provide source of quote Commented Dec 31, 2022 at 16:05
2

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

4
  • 1
    Logged in to what? How? Commented Dec 31, 2022 at 16:05
  • To Docker of course Commented Jan 3, 2023 at 13:04
  • Docker hub? Amazon / Google / Github Docker Registry? Your own registry? Commented Jan 3, 2023 at 15:06
  • When It happened to me, I fixed it with loginning via Docker Desktop, Command line was giving that error when I was trying to pull without login Commented Jan 10, 2023 at 14:08
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)
1
  • 1
    This is not explicit enough about how to check the proxy settings
    – caram
    Commented Nov 10, 2023 at 14:11
1

A restart of your internet connection might solve this.

1
  • 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 "registry-1.docker.io/v2": dial tcp: lookup registry-1.docker.io on ..**.*:**: no such host
    – ahairshi
    Commented Feb 7, 2022 at 6:42
1

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.

1

In my case, the issue was resolved by changing the DNS settings in 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

1
  • It solved my long-time issues. Thank you @santhosh Commented Mar 20 at 9:20
0

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

0

Had same issue, I restarted docker and it worked

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:[email protected]:port"

set https_proxy="https://user:[email protected]:port"
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.

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.

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

On my Mac, I accidentially blocked access for the registry in LittleSnitch . After I removed the block, everything worked again.

0

adding

"/var/run/docker.sock:/var/run/docker.sock"

to volumes and setting

privileged: true

for my runner in config.toml helped me

0

Disabling iCloud Private Relay fixed it in my case.

-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)

1
-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!

Not the answer you're looking for? Browse other questions tagged or ask your own question.