docker镜像pull不下来最终解决方法

pull镜像wordpress下来,但是出现如下错误:

# docker pull wordpress:latest    
Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaitin headers)

查看日志,发现出现如下错误:

#tailf /var/log/messages
Aug 19 16:46:29 docker02 dockerd: time="2019-08-19T16:46:29.157861585+08:00" level=warning msg="Error getting v2 registry: Get https://registry.docker-cn.com/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)"
Aug 19 16:46:29 docker02 dockerd: time="2019-08-19T16:46:29.157965774+08:00" level=info msg="Attempting next endpoint for pull after error: Get https://registry.docker-cn.com/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)"
Aug 19 16:46:44 docker02 dockerd: time="2019-08-19T16:46:44.158651847+08:00" level=warning msg="Error getting v2 registry: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)"
Aug 19 16:46:44 docker02 dockerd: time="2019-08-19T16:46:44.158907684+08:00" level=info msg="Attempting next endpoint for pull after error: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)"
Aug 19 16:46:44 docker02 dockerd: time="2019-08-19T16:46:44.159189201+08:00" level=error msg="Handler for POST /v1.40/images/create returned error: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)"

发现是因为docker加速器超时导致pull不下来
查看加速器:/etc/docker/daemon.json

# cat /etc/docker/daemon.json 
{
"registry-mirrors": ["https://registry.docker-cn.com"],
"insecure-registries": ["10.0.0.12:5000"]
}

导致此问题产生,主要是因为国家把docker国外镜像hub封掉了,导致镜像pull不下来,为此,改用国内的镜像

# cat /etc/docker/daemon.json 
{
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn/","https://hub-mirror.c.163.com","https://registry.docker-cn.com"],
"insecure-registries": ["10.0.0.12:5000"]
}
#systemctl restart docker
# docker pull wordpress:latest
latest: Pulling from library/wordpress
1ab2bdfe9778: Pulling fs layer 
1448c64389e0: Pulling fs layer 
4b8a4e62b444: Pulling fs layer 
9eb9d1e8e241: Pulling fs layer 
d20b2d19292c: Pull complete 
023060ea5930: Pull complete 
a7fa99bc84ac: Pull complete 
138ec8da18f2: Pull complete 
cd4dae5ac262: Pull complete 
c90eff48869a: Pull complete 
1bc49f4d3a43: Pull complete 
e3bb2b10f58d: Pull complete 
fd7b454ec570: Pull complete 
6096f23889f4: Pull complete 
81072ed817d5: Pull complete 
ecce7df16ad3: Pull complete 
f4475635015e: Pull complete 
bad34b7324ad: Pull complete 
890f49d5ad8a: Pull complete 
7e4ee285d305: Pull complete 
Digest: sha256:6566a68d0c613304aa11255d98aba6e29c5fa8cd8497064639343956a4c7d2b1
Status: Downloaded newer image for wordpress:latest
docker.io/library/wordpress:latest

可以正常Pull下来了。

posted @ 2019-08-19 17:04  wang509020  阅读(61564)  评论(1编辑  收藏  举报