问题
这个问题是由于我使用docker pull命令拉取新镜像时频繁报错:
docker pull captainvalk/yesplaymusic:latest
Error response from daemon: Get "https://registry-1.docker.io/v2/captainvalk/yesplaymusic/manifests/sha256:dd8d8659fda26ba883f951d0dbf7d9236957c3a91ff9f00e6167989978a31457": read tcp 192.168.0.158:39888->54.83.42.45:443: read: connection reset by peer
首先的排查思路当然是从镜像仓库着手,所以我尝试把/etc/docker/daemon.json中的镜像加速器还原为默认:
1 {
2 "registry-mirrors": ["https://registry.docker-cn.com"]
3 }
重启docker服务,无效
Tips:其实这个思路是完全错误的,因为我pull的是我上传到dockerhub中自己的镜像,所以不会通过镜像加速器下载。
使用必应搜索一番之后发现原来问题出在指向的registry-1.docker.io IP无法访问。解决方法是通过dig命令在dns中找到registry-1.docker.io能访问的ip,然后在host中修改
解决
dig @114.114.114.114 registry-1.docker.io
; <<>> DiG 9.11.4-P2-RedHat-9.11.4-26.P2.el7_9.9 <<>> @114.114.114.114 registry-1.docker.io
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 11785
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;registry-1.docker.io. IN A
;; ANSWER SECTION:
registry-1.docker.io. 77 IN A 3.215.51.67
registry-1.docker.io. 77 IN A 54.242.59.189
registry-1.docker.io. 77 IN A 54.83.42.45
;; Query time: 11 msec
;; SERVER: 114.114.114.114#53(114.114.114.114)
;; WHEN: Thu Sep 15 09:14:32 CST 2022
;; MSG SIZE rcvd: 86
vim /etc/host
54.242.59.189 registry-1.docker.io #填入指定IP
systemctl restart docker
重启docker服务
成功pull
docker pull captainvalk/yesplaymusic:latest
latest: Pulling from captainvalk/yesplaymusic
8663204ce13b: Already exists
a1484661dfe6: Already exists
2f78a3560d10: Already exists
a517401f7a94: Already exists
294d17c34d13: Already exists
7051f5a2f4b1: Already exists
279ca806a0b4: Already exists
805fa4d25d18: Already exists
7da1afad3cfe: Already exists
8f332da9d959: Pull complete
Digest: sha256:dd8d8659fda26ba883f951d0dbf7d9236957c3a91ff9f00e6167989978a31457
Status: Downloaded newer image for captainvalk/yesplaymusic:latest
docker.io/captainvalk/yesplaymusic:latest