docker search 镜像超时 使用dig解决

安装dig

yum install bind-utils

docker search mysql 时候报错:

[root@dockermaster ~]# docker search mysql
Error response from daemon: Get https://index.docker.io/v1/search?q=mysql&n=25: dial tcp 54.88.253.98: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: dial tcp 35.169.231.249:443: i/o timeout

解决方法如下:

第一步:182.18.32.18 为本机的DNS   通过dig @182.18.32.18  registry-1.docker.io 找到可用IP

[root@dockermaster ~]# dig @182.18.32.18  registry-1.docker.io 

; <<>> DiG 9.9.4-RedHat-9.9.4-61.el7 <<>> @182.18.32.18 registry-1.docker.io
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 1522
;; flags: qr rd ra; QUERY: 1, ANSWER: 8, AUTHORITY: 6, ADDITIONAL: 12


;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;registry-1.docker.io. IN A


;; ANSWER SECTION:
registry-1.docker.io. 60 IN A 52.22.181.254
registry-1.docker.io. 60 IN A 54.152.209.167
registry-1.docker.io. 60 IN A 34.200.90.16
registry-1.docker.io. 60 IN A 34.200.28.105
registry-1.docker.io. 60 IN A 52.204.202.231
registry-1.docker.io. 60 IN A 34.205.207.96
registry-1.docker.io. 60 IN A 54.164.230.151
registry-1.docker.io. 60 IN A 35.169.231.249


;; AUTHORITY SECTION:
io. 118861 IN NS b0.nic.io.
io. 118861 IN NS a2.nic.io.
io. 118861 IN NS c0.nic.io.
io. 118861 IN NS a0.nic.io.
io. 118861 IN NS ns-a1.io.
io. 118861 IN NS ns-a3.io.


;; ADDITIONAL SECTION:
ns-a3.io. 79825 IN A 74.116.178.1
ns-a1.io. 82329 IN A 194.0.1.1
ns-a1.io. 9891 IN AAAA 2001:678:4::1
a0.nic.io. 12120 IN A 65.22.160.17
a0.nic.io. 44508 IN AAAA 2a01:8840:9e::17
a2.nic.io. 12120 IN A 65.22.163.17
a2.nic.io. 20413 IN AAAA 2a01:8840:a1::17
c0.nic.io. 12120 IN A 65.22.162.17
c0.nic.io. 12120 IN AAAA 2a01:8840:a0::17
b0.nic.io. 12120 IN A 65.22.161.17
b0.nic.io. 44508 IN AAAA 2a01:8840:9f::17


;; Query time: 765 msec
;; SERVER: 182.18.32.18#53(182.18.32.18)
;; WHEN: 三 6月 20 09:56:04 CST 2018
;; MSG SIZE  rcvd: 525


第二步:尝试修改/etc/hosts强制docker.io相关的域名解析到其它可用IP

vim /etc/hosts

添加一个可用IP:

52.22.181.254 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.85k

展开阅读全文

没有更多推荐了,返回首页