添加 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://docker.m.daocloud.io",
    "https://dockerpull.com",
    "https://dockerhub.icu"
  ]
}

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

(看网上信息,貌似以组织身份提供的镜像服务基本都停止服务了,现在仅剩一些用爱发电的个人提供的镜像服务了,使用时注意验证镜像一致性!)

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

之后重新启动服务。

$ sudo systemctl daemon-reload
$ sudo systemctl restart docker

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

Registry Mirrors:

https://docker.m.daocloud.io

https://dockerpull.com

https://dockerhub.icu

 测试命令:

# 检查镜像源是否可用
docker pull nginx:latest
docker pull docker.m.daocloud.io/library/nginx:latest
docker pull dockerpull.com/library/nginx:latest
docker pull dockerhub.icu/library/nginx:latest

# 测速
time docker pull nginx:latest
time docker pull docker.m.daocloud.io/library/nginx:latest
time docker pull dockerpull.com/library/nginx:latest
time docker pull dockerhub.icu/library/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
time docker pull registry.cn-hangzhou.aliyuncs.com/library/nginx:latest
time docker pull docker.mirrors.ustc.edu.cn/library/nginx:latest
time docker pull reg-mirror.qiniu.com/library/nginx:latest
time docker pull registry.docker-cn.com/library/nginx:latest
time docker pull mirror.ccs.tencentyun.com/library/nginx:latest
time docker pull dockerhub.azk8s.cn/library/nginx:latest
time 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

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

镜像加速讨论贴:https://gist.github.com/y0ngb1n/7e8f16af3242c7815e7ca2f0833d3ea6

自己搭建加速器:https://mp.weixin.qq.com/s/gVP04sJpt8d0LLMNgquPGQ

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