原 国内Docker Hub镜像加速器还有哪些可用? 解决Docker镜像无法拉取问题(持续更新)
Tags: 原创Docker数据库Docker镜像docker镜像翻墙小麦苗数据库镜像持续更新
前言
去年Docker Hub被封锁,不能直接web浏览;而在今年2024年6月初,不能直接从docker hub拉取镜像了。
之前一直使用的 https://dockerproxy.com/ 也已被墙,所有泛域名已被 GFW 封禁及 DNS 污染,已经无法在中国大陆正常使用。
执行docker pull命令拉取docker镜像时无反应,一直在循环尝试。
1 2 3 4 5 6 7 8 9 10 11 12 | [root@starrocks1 ~]# docker pull mysql:8.1 8.1: Pulling from library/mysql 8e0176adc18c: Pulling fs layer 14e977b0f4b2: Pulling fs layer a7b58dd6f78b: Pulling fs layer fba70cc872a5: Waiting 5db2cc6eab8f: Waiting 081f41f573ba: Waiting 86bf2dc4ded9: Waiting 47f08b0e916e: Waiting 850e29ae8eeb: Waiting 13517fe0d921: Waiting |
下面麦老师整理了几种办法,大家可以参考一下,后期该文持续更新,大家若有新的办法还请不吝赐教。
方法1:修改配置文件
多种方法自行尝试,总有一款适合你,亲测可行!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | -- 可行 docker pull dockerhub.timeweb.cloud/postgres:16.2 docker pull docker.m.daocloud.io/postgres:16.2 docker pull dockerpull.com/postgres:16.2 docker pull docker.chenby.cn/postgres:16.2 docker pull hub.nat.tf/postgres:16.2 docker pull docker.shootchat.top/postgres:16.2 docker pull do.nark.eu.org/postgres:16.2 -- 或直接配置如下加速 cat > /etc/docker/daemon.json <<"EOF" { "registry-mirrors": [ "https://registry.cn-hangzhou.aliyuncs.com", "https://ccr.ccs.tencentyun.com", "https://dockerpull.com", "https://docker.chenby.cn", "https://vm1wbfhf.mirror.aliyuncs.com", "http://f1361db2.m.daocloud.io", "https://hub-mirror.c.163.com", "https://docker.mirrors.ustc.edu.cn", "https://mirror.baidubce.com", "https://ustc-edu-cn.mirror.aliyuncs.com", "https://hub.daocloud.io", "https://docker.shootchat.top", "https://do.nark.eu.org", "https://dockerproxy.com", "https://docker.m.daocloud.io", "https://dockerhub.timeweb.cloud", "https://docker.shootchat.top", "https://do.nark.eu.org" ] } EOF systemctl daemon-reload systemctl restart docker |
方法2:配置代理
若有科学上网的手段,则也可以设置 Docker 代理拉取镜像。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | sudo mkdir -p /etc/systemd/system/docker.service.d cat > /etc/systemd/system/docker.service.d/http-proxy.conf <<"EOF" [Service] Environment="HTTP_PROXY=http://192.16.7.162:9910/" Environment="HTTPS_PROXY=http://192.16.7.162:9910/" Environment="ALL_PROXY=http://192.16.7.162:9910" Environment="NO_PROXY=localhost,127.0.0.1" EOF sudo systemctl daemon-reload sudo systemctl restart docker [root@test /]# sudo docker info | grep Proxy HTTP Proxy: http://192.16.7.162:9910/ HTTPS Proxy: http://192.16.7.162:9910/ No Proxy: localhost,127.0.0.1 |
方法3:单镜像加速
Github仓库地址:https://github.com/kubesre/docker-registry-mirrors
您可以根据 镜像同步 Issue 模板 创建一个 Issue, 将会有机器人帮您优先主动同步指定的镜像 同步结果会在 Issue 中更新
接下来通过案例进行演示一下:
1 2 3 4 5 6 | [root@alldb ~]# docker pull openeuler/openeuler:24.03-lts 24.03-lts: Pulling from openeuler/openeuler 475ac88beb69: Retrying in 1 second 6c642c978813: Retrying in 1 second error pulling image configuration: download failed after attempts=6: dial tcp 118.113.171.186:443: i/o timeout You have mail in /var/spool/mail/root |
那我们提个Issue同步一下:浏览器输入:https://github.com/kubesre/docker-registry-mirrors/issues/new?assignees=&labels=sync+image&projects=&template=sync-image.yml
机器人自动同步,不到1分钟就有回复:
1 2 3 4 5 6 7 8 9 10 11 | # Docker 拉取命令 docker pull swr.cn-east-3.myhuaweicloud.com/kubesre/docker.io/openeuler/openeuler:24.03-lts docker tag swr.cn-east-3.myhuaweicloud.com/kubesre/docker.io/openeuler/openeuler:24.03-lts docker.io/openeuler/openeuler:24.03-lts # Containerd 拉取命令 ctr images pull swr.cn-east-3.myhuaweicloud.com/kubesre/docker.io/openeuler/openeuler:24.03-lts ctr images tag swr.cn-east-3.myhuaweicloud.com/kubesre/docker.io/openeuler/openeuler:24.03-lts docker.io/openeuler/openeuler:24.03-lts # Shell 快速替换命令 sed -i s#docker.io/openeuler/openeuler:24.03-lts#swr.cn-east-3.myhuaweicloud.com/kubesre/docker.io/openeuler/openeuler:24.03-lts#g 你的文件名 |