Docker拉取镜像文件时,遇到错误

Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

可能是网络无法解决,解决办法有很多,本文介绍的使用修改host表方式,但并不代码您遇到问题的原因与我相同。

1、安装bind-utils

yum install bind-utils

2、找出registry-x.docker.io可用的ip

dig @114.114.114.114 registry-1.docker.io

[root@vm1 ~]# dig @114.114.114.114 registry-1.docker.io
; <<>> DiG 9.9.4-RedHat-9.9.4-61.el7 <<>> @114.114.114.114 registry-1.docker.io
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 39101
;; flags: qr rd ra; QUERY: 1, ANSWER: 8, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;registry-1.docker.io. IN A
;; ANSWER SECTION:
registry-1.docker.io. 35 IN A 52.22.181.254
registry-1.docker.io. 35 IN A 52.204.202.231
registry-1.docker.io. 35 IN A 34.200.90.16
registry-1.docker.io. 35 IN A 54.164.230.151
registry-1.docker.io. 35 IN A 34.205.207.96
registry-1.docker.io. 35 IN A 35.169.231.249
registry-1.docker.io. 35 IN A 54.152.209.167
registry-1.docker.io. 35 IN A 34.200.28.105
;; Query time: 13 msec
;; SERVER: 114.114.114.114#53(114.114.114.114)
;; WHEN: 三 5月 30 23:51:27 EDT 2018
;; MSG SIZE rcvd: 177

3、修改host表,添加可用ip

vim /etc/hosts

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

54.152.209.167 registry-1.docker.io

问题解决!

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐