Docker 运行 hello-world 镜像失败或超时
Docker 运行 hello-world 镜像时,可能会遇到连接超时或无法找到本地镜像的错误,报错信息如下:
Unable to find image 'hello-world:latest' locally
Trying to pull repository docker.io/library/hello-world …
/usr/bin/docker-current: missing signature key.
See '/usr/bin/docker-current run --help'.
在安装 Docker 并尝试运行 hello-world 时,遇到连接超时的问题,这通常是因为默认的 Docker 镜像源访问速度较慢或不稳定所导致的。为了加速 Docker 镜像的下载和提升稳定性,解决这个问题的一种有效方法就是更换镜像源。
可以参考官方文档解决步骤。
配置加速地址
第一步:修改配置文件设置 registry mirror。
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": [
"https://do.nark.eu.org",
"https://dc.j8.work",
"https://docker.m.daocloud.io",
"https://dockerproxy.com",
"https://docker.mirrors.ustc.edu.cn",
"https://docker.nju.edu.cn"
]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
systemctl status docker
第二步:重启完 Docker 之后检查 registry mirror 刚刚配置的加速地址是否成功。
docker info
执行后查看输出,确认包含 Registry Mirrors 部分,说明通过上面的命令已经配置成功。
第三步:运行 docker run hello-world。
docker run hello-world
此时我们也可以查看是否成功拉取 hello-world 镜像:
docker images
至此,Docker 运行 hello-world 镜像失败或超时的问题已解决。


