Docker运行hello-world镜像失败或超时

 

测试docker是否运行成功执行docker run hello-world时,报错网络连接失败

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c1ec31eb5944: Retrying in 10 seconds
docker: error pulling image configuration: download failed after attempts=6: dial tcp 128.242.245.93:443: connect: connection refused.
See 'docker run --help'.

 

原因就是我们的镜像源不行,需要更换镜像源 但是我们就算知道原因,去找度娘会发现大部分都是说更换阿里的镜像源,但是我们尝试之后并没有作用

配置加速地址:设置registry mirror

mkdir -p /etc/docker
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刚刚配置的加速地址是否成功

可以看到我们已经配置成功:
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/
Live Restore Enabled: false

运行docker run hello-world,成功运行

 

[root@localhost ~]# docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/

For more examples and ideas, visit:
https://docs.docker.com/get-started/

 

参考:https://blog.csdn.net/m0_51193794/article/details/141396742

 

posted @ 2024-08-28 14:45  Paul7777  阅读(536)  评论(0编辑  收藏  举报