修改 /etc/docker/daemon.json
文件,添加如下镜像源:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| { "registry-mirrors": [ "https://docker.m.daocloud.io", "https://atomhub.openatom.cn", "https://dockerpull.com", "https://docker.1panel.dev", "https://docker.fxxk.dedyn.io", "https://docker.xn--6oq72ry9d5zx.cn", "https://docker.zhai.cm", "https://a.ussh.net", "https://jf4r7fsl.mirror.aliyuncs.com", "http://f1361db2.m.daocloud.io", "https://register.liberx.info", "https://docker.anyhub.us.kg", "https://dockerhub.jobcher.com", "https://dockerhub.icu", "https://dockerhub.awsl9527.cn" ] }
|
或直接使用下面的脚本文件:
- 创建文件
replace.sh
;
- 添加可执行权限
chmod +x replace.sh
- 执行
sudo sh replace.sh
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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| #!/bin/bash
if ! systemctl is-active docker &> /dev/null; then echo "Docker 服务没有正常启动,请检查 Docker 服务状态。" exit 1 fi
DAEMON_JSON="/etc/docker/daemon.json" if [ -f "$DAEMON_JSON" ]; then cp "$DAEMON_JSON" "${DAEMON_JSON}.bak" else touch "$DAEMON_JSON" fi
cat > "$DAEMON_JSON" <<EOF { "registry-mirrors": [ "https://docker.m.daocloud.io", "https://atomhub.openatom.cn", "https://dockerpull.com", "https://docker.1panel.dev", "https://dockerhub.icu", "https://register.liberx.info", "https://dockerpull.com", "https://docker.anyhub.us.kg", "https://dockerhub.jobcher.com", "https://dockerhub.awsl9527.cn" "https://docker.fxxk.dedyn.io", "https://docker.xn--6oq72ry9d5zx.cn", "https://docker.zhai.cm", "https://a.ussh.net", ] } EOF
sudo sudo systemctl daemon-reload
sudo systemctl restart docker
sudo docker pull nginx
if [ $? -eq 0 ]; then echo "Docker 镜像 nginx 拉取成功。" else echo "Docker 镜像 nginx 拉取失败,请检查镜像源配置或网络连接。" fi
|