因为众所周知的原因,在docker官方仓库拉取镜像会特别慢,所以我们需要修改docker镜像地址

在宿主机器编辑文件:vi /etc/docker/daemon.json

请在该配置文件中加入(没有该文件的话,请先建一个):

{"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]}

最后,需要重启docker服务 systemctl restart docker
 

如果还不行的话那么修改下hosts :

[root@docker-registry ~]# yum install bind-utils                          // 安装dig工具
[root@docker-registry ~]# dig @114.114.114.114 registry-1.docker.io
 
; < <>> DiG 9.9.4-RedHat-9.9.4-61.el7_5.1 < <>> @114.114.114.114 registry-1.docker.io
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER< <- opcode: QUERY, status: NOERROR, id: 51198
;; flags: qr rd ra; QUERY: 1, ANSWER: 8, AUTHORITY: 0, ADDITIONAL: 1
 
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;registry-1.docker.io.          IN      A
 
;; ANSWER SECTION:
registry-1.docker.io.   31      IN      A       34.206.236.31
registry-1.docker.io.   31      IN      A       54.175.43.85
registry-1.docker.io.   31      IN      A       34.205.207.96
registry-1.docker.io.   31      IN      A       34.233.151.211
registry-1.docker.io.   31      IN      A       52.70.175.131
registry-1.docker.io.   31      IN      A       34.200.28.105
registry-1.docker.io.   31      IN      A       54.165.149.19
registry-1.docker.io.   31      IN      A       34.201.236.93
 
;; Query time: 10 msec
;; SERVER: 114.114.114.114#53(114.114.114.114)
;; WHEN: Wed Oct 31 11:18:55 CST 2018
;; MSG SIZE  rcvd: 177

选择上面命令执行结果中的一组解析放到本机的/etc/hosts文件里做映射

[root@docker-registry ~]# vim /etc/hosts
54.175.43.85    registry-1.docker.io
Logo

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

更多推荐