0


完美解决Docker pull时报错:https://registry-1.docker.io/v2/

1、错误描述

  1. root@ubuntu-database:/opt/dify/docker# docker compose up -d
  2. [+] Running 9/9
  3. api Error context canceled 15.1s
  4. db Error context canceled 15.1s
  5. nginx Error context canceled 15.1s
  6. redis Error Get "https://registry-1.docker.io/v2/": context deadline exceeded (Client.Timeout exceeded while awaiting headers) 15.1s
  7. ssrf_proxy Error context canceled 15.1s
  8. worker Error context canceled 15.1s
  9. weaviate Error context canceled 15.1s
  10. sandbox Error context canceled 15.1s
  11. web Error context canceled 15.1s
  12. Error response from daemon: Get "https://registry-1.docker.io/v2/": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
  1. Error response from daemon: Get "https://registry-1.docker.io/v2/": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
  2. 这个错误表明Docker客户端尝试访问Docker Hub或其他Docker注册中心时出现了问题。具体来说,是在尝试获取注册中心API的响应时遇到了错误。可能的原因包括网络问题、认证问题、注册中心URL不正确或者注册中心服务本身不可用。

2、解决方法

2.1、检查网络连接

  1. 确保你的机器可以访问互联网,特别是Docker Hub或你所使用的私有注册中心。
  1. root@ubuntu-database:/opt/dify/docker# ping www.baidu.com
  2. PING www.a.shifen.com (110.242.68.3) 56(84) bytes of data.
  3. 64 bytes from 110.242.68.3: icmp_seq=1 ttl=128 time=38.5 ms
  4. 64 bytes from 110.242.68.3: icmp_seq=2 ttl=128 time=36.4 ms
  5. 64 bytes from 110.242.68.3: icmp_seq=3 ttl=128 time=52.3 ms

2.2、检查Docker服务状态

  1. 运行systemctl status dockerLinux系统)查看Docker服务是否正在运行。
  1. root@ubuntu-database:/opt/dify/docker# systemctl status docker
  2. docker.service - Docker Application Container Engine
  3. Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; preset: enabled)
  4. Active: active (running) since Wed 2024-11-27 12:04:05 UTC; 55min ago
  5. TriggeredBy: docker.socket
  6. Docs: https://docs.docker.com
  7. Main PID: 4766 (dockerd)
  8. Tasks: 10
  9. Memory: 21.8M (peak: 24.5M)
  10. CPU: 479ms
  11. CGroup: /system.slice/docker.service

如以上都没有问题,下面考虑docker换源

2.3、换源

  1. sudo mkdir -p /etc/docker
  2. vim /etc/docker/daemon.json

首先进入/etc/docker/daemon.json文件

然后在里面加入下面的配置

  1. {
  2. "registry-mirrors" : ["https://docker.registry.cyou",
  3. "https://docker-cf.registry.cyou",
  4. "https://dockercf.jsdelivr.fyi",
  5. "https://docker.jsdelivr.fyi",
  6. "https://dockertest.jsdelivr.fyi",
  7. "https://mirror.aliyuncs.com",
  8. "https://dockerproxy.com",
  9. "https://mirror.baidubce.com",
  10. "https://docker.m.daocloud.io",
  11. "https://docker.nju.edu.cn",
  12. "https://docker.mirrors.sjtug.sjtu.edu.cn",
  13. "https://docker.mirrors.ustc.edu.cn",
  14. "https://mirror.iscas.ac.cn",
  15. "https://docker.rainbond.cc",
  16. "https://do.nark.eu.org",
  17. "https://dc.j8.work",
  18. "https://dockerproxy.com",
  19. "https://gst6rzl9.mirror.aliyuncs.com",
  20. "https://registry.docker-cn.com",
  21. "http://hub-mirror.c.163.com",
  22. "http://mirrors.ustc.edu.cn/",
  23. "https://mirrors.tuna.tsinghua.edu.cn/",
  24. "http://mirrors.sohu.com/"
  25. ],
  26. "insecure-registries" : [
  27. "registry.docker-cn.com",
  28. "docker.mirrors.ustc.edu.cn"
  29. ],
  30. "debug": true,
  31. "experimental": false
  32. }

重载生效

  1. sudo systemctl daemon-reload

重启服务

  1. sudo systemctl restart docker

查看是否配置成功

  1. docker info
  1. root@ubuntu-database:/etc/docker# docker info
  2. Client: Docker Engine - Community
  3. Version: 27.3.1
  4. Context: default
  5. Debug Mode: false
  6. Plugins:
  7. buildx: Docker Buildx (Docker Inc.)
  8. Version: v0.17.1
  9. Path: /usr/libexec/docker/cli-plugins/docker-buildx
  10. compose: Docker Compose (Docker Inc.)
  11. Version: v2.29.7
  12. Path: /usr/libexec/docker/cli-plugins/docker-compose
  13. Server:
  14. Containers: 0
  15. Running: 0
  16. Paused: 0
  17. Stopped: 0
  18. Images: 0
  19. Server Version: 27.3.1
  20. Storage Driver: overlay2
  21. Backing Filesystem: extfs
  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: systemd
  28. Cgroup Version: 2
  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: 57f17b0a6295a39009d861b89e3b3b87b005ca27
  38. runc version: v1.1.14-0-g2c9f560
  39. init version: de40ad0
  40. Security Options:
  41. apparmor
  42. seccomp
  43. Profile: builtin
  44. cgroupns
  45. Kernel Version: 6.8.0-49-generic
  46. Operating System: Ubuntu 24.04 LTS
  47. OSType: linux
  48. Architecture: x86_64
  49. CPUs: 4
  50. Total Memory: 7.709GiB
  51. Name: ubuntu-database
  52. ID: acb5a888-7140-4e43-8924-6fc325481944
  53. Docker Root Dir: /var/lib/docker
  54. Debug Mode: true
  55. File Descriptors: 23
  56. Goroutines: 40
  57. System Time: 2024-11-27T13:09:10.861401847Z
  58. EventsListeners: 0
  59. Experimental: false
  60. Insecure Registries:
  61. docker.mirrors.ustc.edu.cn
  62. registry.docker-cn.com
  63. 127.0.0.0/8
  64. Registry Mirrors:
  65. https://docker.registry.cyou/
  66. https://docker-cf.registry.cyou/
  67. https://dockercf.jsdelivr.fyi/
  68. https://docker.jsdelivr.fyi/
  69. https://dockertest.jsdelivr.fyi/
  70. https://mirror.aliyuncs.com/
  71. https://dockerproxy.com/
  72. https://mirror.baidubce.com/
  73. https://docker.m.daocloud.io/
  74. https://docker.nju.edu.cn/
  75. https://docker.mirrors.sjtug.sjtu.edu.cn/
  76. https://docker.mirrors.ustc.edu.cn/
  77. https://mirror.iscas.ac.cn/
  78. https://docker.rainbond.cc/
  79. https://do.nark.eu.org/
  80. https://dc.j8.work/
  81. https://gst6rzl9.mirror.aliyuncs.com/
  82. https://registry.docker-cn.com/
  83. http://hub-mirror.c.163.com/
  84. http://mirrors.ustc.edu.cn/
  85. https://mirrors.tuna.tsinghua.edu.cn/
  86. http://mirrors.sohu.com/
  87. Live Restore Enabled: false
  88. WARNING: bridge-nf-call-iptables is disabled
  89. WARNING: bridge-nf-call-ip6tables is disabled

重新执行 :docker compose up -d

出现以下情况,说明问题已解决,如下图:

标签: docker java 容器

本文转载自: https://blog.csdn.net/qingzhumuqingfeng/article/details/144094325
版权归原作者 唐可盐 所有, 如有侵权,请联系我们删除。

“完美解决Docker pull时报错:https://registry-1.docker.io/v2/”的评论:

还没有评论