解决方案
换国内镜像源。我用的是清华的。https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/
自己找自己对应的版本。
例如你的Ubuntu系统。就用下列命令
sudo curl -fsSL https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
其他系统例如 centos
就把上面命令里的 ubuntu 替换为 centos
即可。
其他操作跟官方文档一致。https://docs.docker.com/engine/install/ubuntu/
安装完成后HelloWorld跑不起来,需要配置最新可用的镜像源
⚠️⚠️⚠️ 自 2024-06-06 开始,国内的 Docker Hub 镜像加速器相继停止服务,可选择为 Docker daemon 配置代理或自建镜像加速服务。
参考链接? Docker Hub 镜像加速器 | GitHub
sudo vim /etc/docker/daemon.json
- 1
向文件里添加如下内容。(2024年8月19号添加,如果发现没有用就去上面参考链接看看最新的)
{
"registry-mirrors": [
"https://x9r52uz5.mirror.aliyuncs.com",
"https://dockerhub.icu",
"https://docker.chenby.cn",
"https://docker.1panel.live",
"https://docker.awsl9527.cn",
"https://docker.anyhub.us.kg",
"https://dhub.kubesre.xyz"
]
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
保存后使用两个命令重启docker
sudo systemctl daemon-reload
sudo systemctl restart docker
- 1
- 2
然后使用命令
docker info
- 1
出现的结果中有刚刚配置的几个镜像源就代表成功了。
评论记录:
回复评论: