重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

dockerpull拉取超时的解决方案

最近docker pull镜像的时候非常不稳定,速度慢不说还经常超时失败

天柱ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为成都创新互联公司的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:18982081108(备注:SSL证书合作)期待与您的合作!

Pulling xlxdsj_swagger_ui (swaggerapi/swagger-ui:)...latest: Pulling from swaggerapi/swagger-uiba3557a56b15: Pull complete1a18b9f93d41: Pull complete38ceab6c6432: Pull complete6104f3bd82cc: Pull complete750e0e12d70c: Pull completed7c38a871210: Pull completecbd9bbb7c3b7: Pull complete3d6723371070: Pull complete5e5b2de4487f: Pull complete3c84c9c2d567: Pull complete9e7d57b00bb8: Pull complete5356d2f5be08: Pull completeDigest: sha256:2a746f15dacc2f2e381b3449544b82e6c7604567f05606d957ff5b7cf7d29a47Status: Downloaded newer image for swaggerapi/swagger-ui:latestPulling xlxdsj_swagger_editor (swaggerapi/swagger-editor:)...ERROR: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)大致的解决办法有三个

1、修改DNS

2、修改镜像仓库地址

3、修改hosts

使用socks5代理

以下操作均在CentOS7,Ubuntu与之基本一致,macOS以及windos原理一致

修改DNS>>> vim /etc/resolv.confnameserver 8.8.8.8修改镜像仓库地址>>> vim /etc/docker/daemon.json{ "registry-mirrors": ["https://docker.mirrors.ustc.edu.cn", "https://reg-mirror.qiniu.com"]}>>> systemctl daemon-reload>>> systemctl restart docker修改host# 安装dig>>> sudo yum install bind-utils>>> dig @114.114.114.114 registry-1.docker.io; <<>> DiG 9.11.4-P2-RedHat-9.11.4-26.P2.el7_9.3 <<>> @114.114.114.114 registry-1.docker.io; (1 server found);; global options: +cmd;; Got answer:;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 18733;; flags: qr rd ra; QUERY: 1, ANSWER: 8, AUTHORITY: 0, ADDITIONAL: 1;; OPT PSEUDOSECTION:; EDNS: version: 0, flags:; udp: 512;; QUESTION SECTION:;registry-1.docker.io. IN A;; ANSWER SECTION:registry-1.docker.io. 38 IN A 54.85.56.253registry-1.docker.io. 38 IN A 35.174.73.84registry-1.docker.io. 38 IN A 23.22.155.84registry-1.docker.io. 38 IN A 18.213.137.78registry-1.docker.io. 38 IN A 107.23.149.57registry-1.docker.io. 38 IN A 52.5.11.128registry-1.docker.io. 38 IN A 52.54.232.21registry-1.docker.io. 38 IN A 52.20.56.50;; Query time: 8 msec;; SERVER: 114.114.114.114#53(114.114.114.114);; WHEN: Tue Feb 23 09:03:18 CST 2021;; MSG SIZE rcvd: 177>>> sudo vim /etc/hosts35.174.73.84 registry-1.docker.io使用socks5代理

如果之前的方法效果都不太好再考虑使用这个

前提是已经装好ss

>>> vim /etc/systemd/system/docker.service.d/http-proxy.conf[Service]Environment="HTTP_PROXY=socks5://127.0.0.1:1080">>> systemctl daemon-reload>>> systemctl restart docker>>> systemctl show --property=Environment dockerEnvironment=HTTP_PROXY=socks5://127.0.0.1:1080

补充:解决docker pull镜像报错或者超时的方案,将拉取地址改为国内镜像仓库

docker默认镜像拉取地址为国外仓库下载速度较慢,甚至会报这种错

Error response from daemon: Get https://docker.elastic.co/v2/: net/http: TLS handshake timeout

解决方法修改 /etc/docker/daemon.json 文件并添加上 registry-mirrors 键值。

然后重启docker就可以了

{ "registry-mirrors": ["https://registry.docker-cn.com"]}

以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。如有错误或未考虑完全的地方,望不吝赐教。


分享标题:dockerpull拉取超时的解决方案
当前链接:http://cqcxhl.cn/article/dsijj.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP