docker拉取mysql镜像报错Error response from daemon

Error response from daemon: Head https://registry-1.docker.io/v2/library/mysql/manifests/latest: Get https://auth.docker.io/token?scope=repository%3Alibrary%2Fmysql%3Apull&service=registry.docker.io: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

1.通过dig @114.114.114.114 registry-1.docker.io找到可用IP

[root@localhost ~]# dig @114.114.114.114 registry-1.docker.io

; <<>> DiG 9.11.4-P2-RedHat-9.11.4-26.P2.el7 <<>> @114.114.114.114 registry-1.docker.io
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 64291
;; flags: qr rd ra; QUERY: 1, ANSWER: 8, AUTHORITY: 0, ADDITIONAL: 1

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

;; ANSWER SECTION:
registry-1.docker.io.	34	IN	A	34.231.251.252
registry-1.docker.io.	34	IN	A	54.236.131.166
registry-1.docker.io.	34	IN	A	54.236.165.68
registry-1.docker.io.	34	IN	A	18.213.137.78
registry-1.docker.io.	34	IN	A	35.174.73.84
registry-1.docker.io.	34	IN	A	23.23.116.141
registry-1.docker.io.	34	IN	A	3.224.96.239
registry-1.docker.io.	34	IN	A	52.1.121.53

;; Query time: 28 msec
;; SERVER: 114.114.114.114#53(114.114.114.114)
;; WHEN:313 13:21:34 CST 2021
;; MSG SIZE  rcvd: 177

2.修改/etc/hosts强制docker.io相关的域名解析到其它可用IP,添加34.231.251.252并保存。

vim /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
34.231.251.252 registry-1.docker.io

3.再次拉取

[root@localhost ~]# docker pull mysql
Using default tag: latest
latest: Pulling from library/mysql
a076a628af6f: Pull complete 
f6c208f3f991: Pull complete 
88a9455a9165: Pull complete 
406c9b8427c6: Pull complete 
7c88599c0b25: Pull complete 
25b5c6debdaf: Pull complete 
43a5816f1617: Pull complete 
1a8c919e89bf: Pull complete 
9f3cf4bd1a07: Pull complete 
80539cea118d: Pull complete 
201b3cad54ce: Pull complete 
944ba37e1c06: Pull complete 
Digest: sha256:feada149cb8ff54eade1336da7c1d080c4a1c7ed82b5e320efb5beebed85ae8c
Status: Downloaded newer image for mysql:latest
docker.io/library/mysql:latest

你可能感兴趣的:(docker,mysql)