Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Akagi201/082a9f46ead1381cd52addb5f7be0ed7 to your computer and use it in GitHub Desktop.
Save Akagi201/082a9f46ead1381cd52addb5f7be0ed7 to your computer and use it in GitHub Desktop.
国内的 Docker Hub 镜像加速器,由国内教育机构与各大云服务商提供的镜像加速服务 | Dockerized 实践 https://github.com/y0ngb1n/dockerized

Docker Hub 镜像加速器

国内从 Docker Hub 拉取镜像有时会遇到困难,此时可以配置镜像加速器。Docker 官方和国内很多云服务商都提供了国内加速器服务。

配置加速地址

Ubuntu 16.04+、Debian 8+、CentOS 7+

创建或修改 /etc/docker/daemon.json

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
    "registry-mirrors": [
        "https://1nj0zren.mirror.aliyuncs.com",
        "https://docker.mirrors.ustc.edu.cn",
        "http://f1361db2.m.daocloud.io",
        "https://dockerhub.azk8s.cn"
    ]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

Docker Hub 镜像加速器列表

镜像加速器 镜像加速器地址 专属加速器 其它加速
Docker 中国官方镜像 https://registry.docker-cn.com Docker Hub已关闭
DaoCloud 镜像站 http://f1361db2.m.daocloud.io 可登录,系统分配 Docker Hub
Azure 中国镜像  https://dockerhub.azk8s.cn Docker Hub、GCR、Quay
科大镜像站 https://docker.mirrors.ustc.edu.cn Docker Hub、GCRQuay
阿里云 https://<your_code>.mirror.aliyuncs.com 需登录,系统分配 Docker Hub
七牛云 https://reg-mirror.qiniu.com Docker Hub、GCR、Quay
网易云 https://hub-mirror.c.163.com Docker Hub
腾讯云 https://mirror.ccs.tencentyun.com Docker Hub

检查加速器是否生效

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

Registry Mirrors:
 [...]
 https://dockerhub.azk8s.cn/

Docker Hub 镜像测速

使用镜像前后,可使用 time 统计所花费的总时间。测速前先移除本地的镜像!

$ docker rmi node:latest
$ time docker pull node:latest
Pulling repository node
[...]

real   1m14.078s
user   0m0.176s
sys    0m0.120s

参考链接

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment