解决Error response from daemon: Get https://registry-1.docker.io/v2/library/hello-world/manifests/
<article class="baidu_pl" style="box-sizing: inherit; outline: 0px; display: block; position: relative; padding-top: 16px;">
昨天在使用docker 时,将 image 文件从仓库抓取到本地一直报错,经过尝试,终于得以解决。
错误信息如下:
[root@archlinux ~]# docker image pull library/hello-world
Using default tag: latest
Error response from daemon: Get [https://registry-1.docker.io/v2/library/hello-world/manifests/latest](https://registry-1.docker.io/v2/library/hello-world/manifests/latest): dial tcp 52.20.146.203:443: i/o timeout
或者:
> [root@archlinux quanxj]# docker image pull library/hello-world
> Using default tag: latest
> latest: Pulling from library/hello-world
> ca4f61b1923c: Pull complete
> error pulling image configuration: Get [https://registry-1.docker.io/v2/library/hello-world/blobs/sha256:f2a91732366c0332ccd7afd2a5c4ff2b9af81f549370f7a19acd460f87686bc7](https://registry-1.docker.io/v2/library/hello-world/blobs/sha256:f2a91732366c0332ccd7afd2a5c4ff2b9af81f549370f7a19acd460f87686bc7): dial tcp 35.169.231.249:443: i/o timeout
解决方法如下:
第一步:通过dig @114.114.114.114 registry-1.docker.io
找到可用IP
> [root@archlinux ~]# dig @114.114.114.114 registry-1.docker.io
> ; <<>> DiG 9.12.0 <<>> @114.114.114.114 registry-1.docker.io
> ; (1 server found)
> ;; global options: +cmd
> ;; Got answer:
> ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 37534
> ;; flags: qr rd ra; QUERY: 1, ANSWER: 8, AUTHORITY: 0, ADDITIONAL: 1
> ;; OPT PSEUDOSECTION:
> ; EDNS: version: 0, flags:; udp: 4096
> ; COOKIE: 88f87a15f4ca45dc (echoed)
> ;; QUESTION SECTION:
> ;registry-1.docker.io. IN A
> ;; ANSWER SECTION:
> registry-1.docker.io. 30 IN A 34.200.28.105
> registry-1.docker.io. 30 IN A 52.22.181.254
> registry-1.docker.io. 30 IN A 35.169.231.249
> registry-1.docker.io. 30 IN A 52.5.185.86
> registry-1.docker.io. 30 IN A 54.164.230.151
> registry-1.docker.io. 30 IN A 34.200.90.16
> registry-1.docker.io. 30 IN A 52.20.146.203
> registry-1.docker.io. 30 IN A 52.206.156.207
> ;; Query time: 116 msec
> ;; SERVER: 114.114.114.114#53(114.114.114.114)
> ;; WHEN: 四 3月 08 09:27:12 CST 2018
> ;; MSG SIZE rcvd: 189
第二步:尝试修改/etc/hosts
强制docker.io相关的域名解析到其它可用IP
> vim /etc/hosts
添加一个可用IP:
52.5.185.86 registry-1.docker.io
保存之后重试:
> [root@archlinux quanxj]# docker image pull library/hello-world
> Using default tag: latest
> latest: Pulling from library/hello-world
> ca4f61b1923c: Already exists
> Digest: sha256:083de497cff944f969d8499ab94f07134c50bcf5e6b9559b27182d3fa80ce3f7
> Status: Downloaded newer image for hello-world:latest
验证:
> [root@archlinux quanxj]# docker image ls
> REPOSITORY TAG IMAGE ID CREATED SIZE
> hello-world latest f2a91732366c 3 months ago 1.85kB
成功!
</article>