当前位置: 代码网 > 服务器>服务器>云虚拟主机 > Docker运行hello-world镜像失败或超时的问题

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

2024年10月28日 云虚拟主机 我要评论
docker run hello-world时超时告警​ 跟着官方文档进行docker安装时,测试docker是否运行成功执行docker run hello-world时,结果和别人的不一样正常情况

docker run hello-world时超时告警

​ 跟着官方文档进行docker安装时,测试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'.

原因:就是我们的镜像源不行,需要更换镜像源

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

常规方案没作用

#针对docker客户端版本大于 1.10.0 的用户
#您可以通过修改daemon配置文件/etc/docker/daemon.json来使用加速器
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'eof'
{
  "registry-mirrors": ["https://5nkcn10r.mirror.aliyuncs.com"]
}
eof
sudo systemctl daemon-reload
sudo systemctl restart docker

2.1、解决方案

配置加速地址:设置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刚刚配置的加速地址是否成功

[root@wzy1303 docker]# docker info
client: docker engine - community
 version:    26.1.4
 context:    default
 debug mode: false
 plugins:
  buildx: docker buildx (docker inc.)
    version:  v0.14.1
    path:     /usr/libexec/docker/cli-plugins/docker-buildx
  compose: docker compose (docker inc.)
    version:  v2.27.1
    path:     /usr/libexec/docker/cli-plugins/docker-compose
server:
 containers: 1
  running: 0
  paused: 0
  stopped: 1
 images: 1
 server version: 26.1.4
 storage driver: overlay2
  backing filesystem: xfs
  supports d_type: true
  using metacopy: false
  native overlay diff: true
  userxattr: false
 logging driver: json-file
 cgroup driver: cgroupfs
 cgroup version: 1
 plugins:
  volume: local
  network: bridge host ipvlan macvlan null overlay
  log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 swarm: inactive
 runtimes: io.containerd.runc.v2 runc
 default runtime: runc
 init binary: docker-init
 containerd version: d2d58213f83a351ca8f528a95fbd145f5654e957
 runc version: v1.1.12-0-g51d5e94
 init version: de40ad0
 security options:
  seccomp
   profile: builtin
 kernel version: 3.10.0-1160.119.1.el7.x86_64
 operating system: centos linux 7 (core)
 ostype: linux
 architecture: x86_64
 cpus: 8
 total memory: 2.761gib
 name: wzy1303
 id: 74efae68-ef43-45a9-b547-ffa2c3805423
 docker root dir: /var/lib/docker
 debug mode: false
 username: inkling1303
 experimental: false
 insecure registries:
  127.0.0.0/8
 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@wzy1303 docker]# docker run hello-world
unable to find image 'hello-world:latest' locally
latest: pulling from library/hello-world
c1ec31eb5944: pull complete 
digest: sha256:53cc4d415d839c98be39331c948609b659ed725170ad2ca8eb36951288f81b75
status: downloaded newer image for hello-world:latest
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/
#查看是否成功拉取hello-world镜像
[root@wzy1303 docker]# docker images
repository    tag       image id       created         size
hello-world   latest    d2c94e258dcb   15 months ago   13.3kb
[root@wzy1303 docker]# docker images -a
repository    tag       image id       created         size
hello-world   latest    d2c94e258dcb   15 months ago   13.3kb
[root@wzy1303 docker]# docker images -aq
d2c94e258dcb

到此这篇关于docker运行hello-world镜像失败或超时的问题的文章就介绍到这了,更多相关docker hello-world超时内容请搜索代码网以前的文章或继续浏览下面的相关文章希望大家以后多多支持代码网!

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com