添加 docker hub 的 mirrors 镜像源,加速镜像获取

Ubuntu 16.04+、Debian 8+、CentOS 7
对于使用 systemd 的系统,请在 /etc/docker/daemon.json 中写入如下内容

(如果文件不存在请新建该文件:$ sudo touch /etc/docker/daemon.json)

(非 root 编辑:$ sudo vim /etc/docker/daemon.json)

{
  "registry-mirrors": [
"https://dockerproxy.com", "https://docker.mirrors.sjtug.sjtu.edu.cn" ] }

(目前似乎没有什么公开的加速镜像了,Azure 中国限制内部使用,阿里云需要登录帐号获取加速地址,其它能搜到的镜像地址都不能访问了,就剩 163 和 百度似乎还没报错,但是也没有公开的官方页面承诺提供服务)

注意,一定要保证该文件符合 json 规范,否则 Docker 将不能启动。

之后重新启动服务。

$ sudo systemctl daemon-reload
$ sudo systemctl restart docker

执行 $ sudo docker info,如果从结果中看到了如下内容,说明配置成功。

Registry Mirrors:

https://dockerproxy.com

https://docker.mirrors.sjtug.sjtu.edu.cn

 测试命令:

# 检查镜像源是否可用
docker pull nginx:latest
docker pull dockerproxy.com/library/nginx:latest
docker pull hub-mirror.c.163.com/library/nginx:latest
docker pull docker.mirrors.sjtug.sjtu.edu.cn/library/nginx:latest
docker pull mirror.baidubce.com/library/nginx:latest

# 测速
time docker pull nginx:latest
time docker pull dockerproxy.com/library/nginx:latest
time docker pull hub-mirror.c.163.com/library/nginx:latest
time docker pull docker.mirrors.sjtug.sjtu.edu.cn/library/nginx:latest
time docker pull mirror.baidubce.com/library/nginx:latest

# 经测试不可用的镜像源
docker pull registry.cn-hangzhou.aliyuncs.com/library/nginx:latest
docker pull docker.mirrors.ustc.edu.cn/library/nginx:latest
docker pull reg-mirror.qiniu.com/library/nginx:latest
docker pull registry.docker-cn.com/library/nginx:latest
docker pull mirror.ccs.tencentyun.com/library/nginx:latest
docker pull dockerhub.azk8s.cn/library/nginx:latest
docker pull ccr.ccs.tencentyun.com/library/nginx:latest

参考:

https://yeasy.gitbooks.io/docker_practice/install/mirror.html

https://ieevee.com/tech/2016/09/28/docker-mirror.html

https://docs.docker.com/registry/recipes/mirror/

https://juejin.cn/post/7165806699461378085

============================================================

最近又搜到几个公开提供镜像的网站,可以参考使用:

Docker Proxy:https://dockerproxy.com/docs

上海交通大学:https://mirrors.sjtug.sjtu.edu.cn/docs/docker-registry

posted @ 2020-02-09 16:32  不是豆豆  阅读(4028)  评论(0编辑  收藏  举报
友情链接:迷途