当我们使用docker下载镜像时报错:

[root@lyy local]# docker pull tomcat
Using default tag: latest
Trying to pull repository docker.io/library/tomcat ... 
Get https://registry-1.docker.io/v2/library/tomcat/manifests/latest: Get https://auth.docker.io/token?scope=repository%3Alibrary%2Ftomcat%3Apull&service=registry.docker.io: net/http: request canceled (Client.Timeout exceeded while awaiting headers)

解决方法:

[root@lyy local]# yum install bind-utils     安装dig工具
[root@lyy local]# dig @114.114.114.114 registry-1.docker.io
; <<>> DiG 9.9.4-RedHat-9.9.4-74.el7_6.2 <<>> @114.114.114.114 registry-1.docker.io
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 31043
;; 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.   35      IN      A       34.201.196.144
registry-1.docker.io.   35      IN      A       34.199.77.19
registry-1.docker.io.   35      IN      A       34.199.40.84
registry-1.docker.io.   35      IN      A       34.232.31.24
registry-1.docker.io.   35      IN      A       52.2.186.244
registry-1.docker.io.   35      IN      A       52.55.198.220
registry-1.docker.io.   35      IN      A       34.197.189.129
registry-1.docker.io.   35      IN      A       34.228.211.243

;; Query time: 12 msec
;; SERVER: 114.114.114.114#53(114.114.114.114)
;; WHEN:918 13:11:42 CST 2019
;; MSG SIZE  rcvd: 177

选择上面命令执行结果中ANSWER SECTION:下的一组解析IP,放到本机的 /etc/hosts 文件里做映射,示例:

[root@docker-registry ~]# vi /etc/hosts
34.199.77.19    registry-1.docker.io

接下来在进行pull命令,等待下载完成

在这里插入图片描述

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐