docker不能访问官方仓库,现在做一个国内镜像源配置

1.安装好doker并启动

[root@localhost selinux]# systemctl start docker

2.找到docker配置文件daemon.json

如果没有就自己创建

[root@localhost selinux]# vim /etc/docker/daemon.json

3.将以下内容粘贴进入daemon.json,文件中以前的内容可以清空

{
  "exec-opts": ["native.cgroupdriver=systemd"],
  "registry-mirrors": ["https://hub.xdark.top","https://hub.littlediary.cn","https://dockerpull.org","https://hub.crdz.gq","http://docker.lpanel.live","https://docker.unsee.tech","https://docker.udayun.com","https://docker.kejilion.pro","https://registry.dockermirror.com","https://docker.rainbond.cc","https://hub.geekery.cn","https://docker.lpanelproxy.com","https://docker.linkedbus.com","https://docker.nastool.d","https://docker.m.daocloud.io","https://docker.rainbond.cc","https://docker.lmirr0r.top"]
}

# 上述内容包含了国内大多开源的镜像加速站

4.配置生效并重启docker

[root@localhost docker]# systemctl daemon-reload			#加载daemon文件
[root@localhost docker]# systemctl restart docker			#重启docker

5.验证,pull一个mysql镜像做测试

[root@localhost ceshi]# docker pull mysql:5.7
5.7: Pulling from library/mysql
5.7: Pulling from library/mysql
20e4dcae4c69: Downloading 
1c56c3d4ce74: Download complete 
e9f03a1c24ce: Downloading 
68c3898c2015: Downloading 
6b95a940e7b6: Downloading 
90986bb8de6e: Downloading 
ae71319cb779: Downloading 
ffc89e9dfd88: Downloading 
43d05e938198: Downloading 
064b2d298fba: Downloading 
df9a4d85569b: Downloading 
5.7: Pulling from library/mysql
20e4dcae4c69: Pull complete 
1c56c3d4ce74: Pull complete 
e9f03a1c24ce: Pull complete 
68c3898c2015: Pull complete 
6b95a940e7b6: Pull complete 
90986bb8de6e: Pull complete 
ae71319cb779: Pull complete 
ffc89e9dfd88: Pull complete 
43d05e938198: Pull complete 
064b2d298fba: Pull complete 
df9a4d85569b: Pull complete 
Digest: sha256:4bc6bc963e6d8443453676cae56536f4b8156d78bae03c0145cbe47c2aad73bb
Status: Downloaded newer image for mysql:5.7
docker.io/library/mysql:5.7

更多推荐