拉取docker中的镜像时报错:
[root@master ~]# docker pull docker.io/centos:latest
Trying to pull repository docker.io/library/centos ...
Pulling repository docker.io/library/centos
Error while pulling image: Get https://index.docker.io/v1/repositories/library/centos/images: x509: certificate is valid for ruijie, not index.docker.io
解决办法:
1.执行 yum install bind-utils,安装dig工具。
[root@master ~]# yum install bind-utils
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
软件包 32:bind-utils-9.11.4-9.P2.el7.x86_64 已安装并且是最新版本
无须任何处理
2.通过dig @114.114.114.114 registry-1.docker.io
找到可用IP
dig @114.114.114.114 registry-1.docker.io
; <<>> DiG 9.11.4-P2-RedHat-9.11.4-9.P2.el7 <<>> @114.114.114.114 registry-1.docker.io
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 55375
;; flags: qr rd ra; QUERY: 1, ANSWER: 8, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;registry-1.docker.io. IN A
;; ANSWER SECTION:
registry-1.docker.io. 30 IN A 52.201.142.14
registry-1.docker.io. 30 IN A 34.232.31.24
registry-1.docker.io. 30 IN A 52.2.186.244
registry-1.docker.io. 30 IN A 52.202.253.107
registry-1.docker.io. 30 IN A 54.210.105.17
registry-1.docker.io. 30 IN A 52.87.94.70
registry-1.docker.io. 30 IN A 34.228.211.243
registry-1.docker.io. 30 IN A 52.55.198.220
;; Query time: 3 msec
;; SERVER: 114.114.114.114#53(114.114.114.114)
;; WHEN: 四 12月 19 10:27:40 CST 2019
;; MSG SIZE rcvd: 166
3.选择上面命令执行结果中的一组解析放到本机的/etc/hosts文件里做映射
vim /etc/hosts
插入 34.232.31.24 registry-1.docker.io
然后保存。
4.接着执行拉取镜像的操作。
docker pull docker.io/centos
Using default tag: latest
Trying to pull repository docker.io/library/centos ...
latest: Pulling from docker.io/library/centos
Digest: sha256:f94c1d992c193b3dc09e297ffd54d8a4f1dc946c37cbeceb26d35ce1647f88d9
5.检测是否拉取成功。
[root@master ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/centos latest 0f3e07c0138f 11 weeks ago 219.5 MB