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

李优秀  金牌会员 | 2024-9-17 16:22:00 | 来自手机 | 显示全部楼层 | 阅读模式
打印 上一主题 下一主题

主题 565|帖子 565|积分 1695

docker run hello-world时超时告警

​ 跟着官方文档进行docker安装时,测试docker是否运行成功执行docker run hello-world时,效果和别人的不一样
正常情况:

我们的:

  1. Unable to find image 'hello-world:latest' locally
  2. latest: Pulling from library/hello-world
  3. c1ec31eb5944: Retrying in 10 seconds
  4. docker: error pulling image configuration: download failed after attempts=6: dial tcp 128.242.245.93:443: connect: connection refused.
  5. See 'docker run --help'.
复制代码
  原因:就是我们的镜像源不可,需要更换镜像源
  但是我们就算知道原因,去找度娘会发现大部门都是说更换阿里的镜像源,但是我们实行之后并没有作用
   常规方案没作用
  1. #针对Docker客户端版本大于 1.10.0 的用户
  2. #您可以通过修改daemon配置文件/etc/docker/daemon.json来使用加速器
  3. sudo mkdir -p /etc/docker
  4. sudo tee /etc/docker/daemon.json <<-'EOF'
  5. {
  6.   "registry-mirrors": ["https://5nkcn10r.mirror.aliyuncs.com"]
  7. }
  8. EOF
  9. sudo systemctl daemon-reload
  10. sudo systemctl restart docker
复制代码
2.1、解决方案
配置加速地址:设置registry mirror
  1. sudo mkdir -p /etc/docker
  2. sudo tee /etc/docker/daemon.json <<-'EOF'
  3. {
  4.     "registry-mirrors": [
  5.         "https://do.nark.eu.org",
  6.         "https://dc.j8.work",
  7.         "https://docker.m.daocloud.io",
  8.         "https://dockerproxy.com",
  9.         "https://docker.mirrors.ustc.edu.cn",
  10.         "https://docker.nju.edu.cn"
  11.     ]
  12. }
  13. EOF
  14. sudo systemctl daemon-reload
  15. sudo systemctl restart docker
  16. systemctl status docker
复制代码
重启完docker之后查抄registry mirror刚刚配置的加速地址是否成功
  1. [root@wzy1303 docker]# docker info
  2. Client: Docker Engine - Community
  3. Version:    26.1.4
  4. Context:    default
  5. Debug Mode: false
  6. Plugins:
  7.   buildx: Docker Buildx (Docker Inc.)
  8.     Version:  v0.14.1
  9.     Path:     /usr/libexec/docker/cli-plugins/docker-buildx
  10.   compose: Docker Compose (Docker Inc.)
  11.     Version:  v2.27.1
  12.     Path:     /usr/libexec/docker/cli-plugins/docker-compose
  13. Server:
  14. Containers: 1
  15.   Running: 0
  16.   Paused: 0
  17.   Stopped: 1
  18. Images: 1
  19. Server Version: 26.1.4
  20. Storage Driver: overlay2
  21.   Backing Filesystem: xfs
  22.   Supports d_type: true
  23.   Using metacopy: false
  24.   Native Overlay Diff: true
  25.   userxattr: false
  26. Logging Driver: json-file
  27. Cgroup Driver: cgroupfs
  28. Cgroup Version: 1
  29. Plugins:
  30.   Volume: local
  31.   Network: bridge host ipvlan macvlan null overlay
  32.   Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
  33. Swarm: inactive
  34. Runtimes: io.containerd.runc.v2 runc
  35. Default Runtime: runc
  36. Init Binary: docker-init
  37. containerd version: d2d58213f83a351ca8f528a95fbd145f5654e957
  38. runc version: v1.1.12-0-g51d5e94
  39. init version: de40ad0
  40. Security Options:
  41.   seccomp
  42.    Profile: builtin
  43. Kernel Version: 3.10.0-1160.119.1.el7.x86_64
  44. Operating System: CentOS Linux 7 (Core)
  45. OSType: linux
  46. Architecture: x86_64
  47. CPUs: 8
  48. Total Memory: 2.761GiB
  49. Name: wzy1303
  50. ID: 74efae68-ef43-45a9-b547-ffa2c3805423
  51. Docker Root Dir: /var/lib/docker
  52. Debug Mode: false
  53. Username: inkling1303
  54. Experimental: false
  55. Insecure Registries:
  56.   127.0.0.0/8
  57. Registry Mirrors:
  58.   https://do.nark.eu.org/
  59.   https://dc.j8.work/
  60.   https://docker.m.daocloud.io/
  61.   https://dockerproxy.com/
  62.   https://docker.mirrors.ustc.edu.cn/
  63.   https://docker.nju.edu.cn/
  64. Live Restore Enabled: false
复制代码
可以看到我们已经配置成功:

运行docker run hello-world,成功运行
  1. [root@wzy1303 docker]# docker run hello-world
  2. Unable to find image 'hello-world:latest' locally
  3. latest: Pulling from library/hello-world
  4. c1ec31eb5944: Pull complete
  5. Digest: sha256:53cc4d415d839c98be39331c948609b659ed725170ad2ca8eb36951288f81b75
  6. Status: Downloaded newer image for hello-world:latest
  7. Hello from Docker!
  8. This message shows that your installation appears to be working correctly.
  9. To generate this message, Docker took the following steps:
  10. 1. The Docker client contacted the Docker daemon.
  11. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
  12.     (amd64)
  13. 3. The Docker daemon created a new container from that image which runs the
  14.     executable that produces the output you are currently reading.
  15. 4. The Docker daemon streamed that output to the Docker client, which sent it
  16.     to your terminal.
  17. To try something more ambitious, you can run an Ubuntu container with:
  18. $ docker run -it ubuntu bash
  19. Share images, automate workflows, and more with a free Docker ID:
  20. https://hub.docker.com/
  21. For more examples and ideas, visit:
  22. https://docs.docker.com/get-started/
  23. #查看是否成功拉取hello-world镜像
  24. [root@wzy1303 docker]# docker images
  25. REPOSITORY    TAG       IMAGE ID       CREATED         SIZE
  26. hello-world   latest    d2c94e258dcb   15 months ago   13.3kB
  27. [root@wzy1303 docker]# docker images -a
  28. REPOSITORY    TAG       IMAGE ID       CREATED         SIZE
  29. hello-world   latest    d2c94e258dcb   15 months ago   13.3kB
  30. [root@wzy1303 docker]# docker images -aq
  31. d2c94e258dcb
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

使用道具 举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

李优秀

金牌会员
这个人很懒什么都没写!

标签云

快速回复 返回顶部 返回列表