How to fix Docker's “Error pulling image…too many redirects” failures while pulling images from registry?

↘锁芯ラ 提交于 2019-11-28 05:20:50

Try this temporary workaround:

osx$ boot2docker up
osx$ boot2docker ssh
docker@boot2docker$ sudo echo "nameserver 8.8.8.8" > /etc/resolv.conf
docker@boot2docker$ sudo /etc/init.d/docker restart

It works until reboot.

I don't know about OS X, but on linux this could happen due to "bad" /etc/resolv.conf on the host. For example, ubuntu puts something like:

nameserver 127.0.1.1

and then handles the DNS requests through some service. The problem is, that this is accessible from inside of the image.

To fix this, I had to add some external nameservers, like:

nameserver 127.0.1.1
nameserver 8.8.8.8
nameserver 8.8.4.4

I had a similar issue when trying to pull a container from docker repository with this command :
docker pull ubuntu

Note that I was using coreos inside virtualbox and I was using Nat as my Networking Configuration to have access to internet. When Switching network modes with virtualbox, I couldn't do any pull.

I solved the issue by restarting docker with systemctl by iniating this command :
sudo systemctl restart docker

And then my pull worked fine. I hope this solution helped you. And I got it from from google group issue addressed by one of CoreOS creators(Brandon Philips) through this link: https://groups.google.com/forum/#!topic/coreos-dev/vWqSbPgNYro

10.0.2.3 is virtualbox dns server, check Fine-tuning the VirtualBox NAT engine

You can as other suggested use 8.8.8.8 which is google dns server.

# /etc/resolve.conf
nameserver 8.8.8.8

And if you work in intranet, then replace it with your normal dns server, which you can add search as well like below

# /etc/resolve.conf
nameserver xxx.xxxx.xxx
search company.com

This will be good to access your private repo

On MacOSX, if you use Docker Machine you can try to:

 docker-machine ls
 docker-machine ssh YOUR_VM_NAME

and then from within the VM: kill the /usr/local/bin/docker process and start it again by hand:

 sudo /usr/local/bin/docker -d -D -g /var/lib/docker -H unix:// -H tcp://0.0.0.0:2376 --label provider=virtualbox --tlsverify --tlscacert=/var/lib/boot2docker/ca.pem --tlscert=/var/lib/boot2docker/server.pem --tlskey=/var/lib/boot2docker/server-key.pem -s aufs

Funnily enough, restarting like this

sudo /etc/init.d/docker restart

does not help.

On windows I was able to fix it by doing the following:

  1. Go to virtual box application
  2. Delete the VM that was created
  3. Restart computer (optional, i think)
  4. Start Kitematic
  5. Go back to Virtual Box, hit show
  6. Make sure ping google.com command works

Now I am able to download docker images from the hub.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!