Docker pull拉取镜像报错“Error response from daemon: Get "https://registry-1.docker.io/v2”解决办法(已经排除网络原因,仍无法拉取)
一、报错信息
[root@localhost ~]# docker pull nginx
Using default tag: latest
Error response from daemon: Get "https://registry-1.docker.io/v2/": context deadline exceeded
二、检查daemon.json 文件
[root@localhost ~]# cat /etc/docker/daemon.json
{"registry-mirrors": ["https://registry.docker-cn.com","http://hub-mirror.c.163.com"]}
如果没有文件创建编辑(可额外添加阿里云的镜像加速阿里云镜像加速器)
1.编辑daemon.json
{"registry-mirrors": ["https://registry.docker-cn.com","http://hub-mirror.c.163.com"]}
2.重启服务
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl restart docker
三、查看dns解析
[root@localhost ~]# dig @114.114.114.114 registry-1.docker.io
;; ANSWER SECTION:
registry-1.docker.io. 74 IN A 3.216.34.172
registry-1.docker.io. 74 IN A 34.205.13.154
registry-1.docker.io. 74 IN A 44.205.64.79
四、添加host解析
[root@localhost ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
3.216.34.172 registry-1.docker.io
五、重新拉取镜像
[root@localhost ~]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
31b3f1ad4ce1: Downloading
fd42b079d0f8: Download complete
30585fbbebc6: Download complete
18f4ffdd25f4: Download complete
9dc932c8fba2: Download complete
600c24b8ba39: Download complete
解决