docker 出现 Error response from daemon

时间:2024-01-20 19:35:57

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

navy@deepin:~/Desktop$ dig @114.114.114.114 registry-.docker.io

; <<>> DiG 9.11.--Debian <<>> @114.114.114.114 registry-.docker.io
; ( server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id:
;; flags: qr rd ra; QUERY: , ANSWER: , AUTHORITY: , ADDITIONAL: ;; QUESTION SECTION:
;registry-.docker.io. IN A ;; ANSWER SECTION:
registry-.docker.io. IN A 34.200.28.105
registry-.docker.io. IN A 52.22.67.152
registry-.docker.io. IN A 52.70.175.131
registry-.docker.io. IN A 52.22.201.61
registry-.docker.io. IN A 52.54.155.177
registry-.docker.io. IN A 52.206.40.44
registry-.docker.io. IN A 54.175.43.85
registry-.docker.io. IN A 54.165.149.19 ;; AUTHORITY SECTION:
docker.io. IN NS ns-.awsdns-.co.uk.
docker.io. IN NS ns-.awsdns-.com.
docker.io. IN NS ns-.awsdns-.org.
docker.io. IN NS ns-.awsdns-.net. ;; ADDITIONAL SECTION:
ns-.awsdns-.co.uk. IN A 205.251.199.35
ns-.awsdns-.com. IN A 205.251.193.165
ns-.awsdns-.org. IN A 205.251.196.144
ns-.awsdns-.net. IN A 205.251.194.1 ;; Query time: msec
;; SERVER: 114.114.114.114#(114.114.114.114)
;; WHEN: Sun Nov :: CST
;; MSG SIZE rcvd:

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

vim /etc/hosts

添加一个可用IP:

34.200.28.105 registry-.docker.io

保存之后重试:

navy@deepin:~/Desktop$ sudo docker pull ubuntu
Using default tag: latest
latest: Pulling from library/ubuntu
473ede7ed136: Pull complete
c46b5fa4d940: Pull complete
93ae3df89c92: Pull complete
6b1eed27cade: Pull complete
Digest: sha256:29934af957c53004d7fb6340139880d23fb1952505a15d69a03af0d1418878cb
Status: Downloaded newer image for ubuntu:latest

验证:

navy@deepin:~/Desktop$ sudo docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest ea4c82dcd15a weeks ago .8MB

成功!