> 技术文档 > docker hub 拉取镜像失败报Get “https://registry-1.docker.io/v2/“: net/http: request canceled while waiting _docker配置了阿里云镜像还是pull不了报request canceled while wait

docker hub 拉取镜像失败报Get “https://registry-1.docker.io/v2/“: net/http: request canceled while waiting _docker配置了阿里云镜像还是pull不了报request canceled while wait

自己记录一把,给兄弟们避坑

1.上问题报错代码

[root@localhost ~]# docker pull hello-worldUsing default tag: latestError response from daemon: Get \"https://registry-1.docker.io/v2/\": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

2.尝试的方法

        2.1 配置阿里镜像加速

        

[root@localhost etc]# cat /etc/docker/daemon.json{ \"registry-mirrors\": [ \"https://xxxxxx.mirror.aliyuncs.com\" #登录阿里云获取镜像加速的仓库地址,配进来即可 ]}#配置完后注意重载服务 systemctl daemon-reload systemctl restart docker

        2.2 配置宿主机代理 

以临时配置为例:

查看环境变量 env

手动配置http_proxy 和 https_proxy   代理自己想办法

export http_proxy=\"http://IP:port\"export https_proxy=\"http://IP:port\"

完成后先测试服务器到代理的连通性,再测试服务器到目标地址的连通性。

先看到200说明连接是正常的,之后的401以为是认证问题。开始手动琢磨登录docker hub后再次拉取。问题依旧。

3.最终解决方案

为docker 服务配置代理。默认安装的docker 引擎和官网都没有这一块内容。

手动创建这个文件   /etc/systemd/system/docker.service.d/http-proxy.conf

[Service]Environment=http_proxy=http://IP:PORT/Environment=no_proxy=localhost,127.0.0.1Environment=https_proxy=http://IP:PORT/保存文件后再次重载服务systemctl daemon-reloadsystemctl restart docker

拉取镜像成功

我记得1年前好像没这个问题。这个变化还是挺坑的。

虽然AI很牛,但有些问题只能找专业社区去查资料

参考链接

https://stackoverflow.com/questions/51571686/ubuntu-18-04-error-response-from-daemon-get-https-registry-1-docker-io-v2/51648635#51648635