我该如何修复 Ubuntu 20.04 中的这个问题?
[18:31:29] (dpcc) jalal@echo:~/research/code$ sudo docker pull docurdt/heal
[sudo] password for jalal:
Using default tag: latest
Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
$ uname -a
Linux echo 5.4.0-99-generic #112-Ubuntu SMP Thu Feb 3 13:50:55 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
$ docker --version
Docker version 20.10.7, build 20.10.7-0ubuntu5~20.04.2
我在 CentOS 7 上使用 $ docker pull 时没有遇到任何问题。
以下是我使用过的代理~/.bashrc
:
export http_proxy="http://webproxy.bu.edu:8900"
export https_proxy="http://webproxy.bu.edu:8900"
export ftp_proxy="http://webproxy.bu.edu:8900"
export rsync_proxy=$http_proxy
export no_proxy="localhost,127.0.0.1,.bu.edu,.ad.bu.edu,128.197.,10."
添加这些内容config.json
但注销后错误仍然存在:
$ cat ~/.docker/config.json
{
"proxies":
{
"default":
{
"httpProxy": "http://webproxy.bu.edu:8900",
"httpsProxy": "http://webproxy.bu.edu:8900",
"noProxy": "localhost,127.0.0.1,.bu.edu,.ad.bu.edu,128.197.,10."
}
}
}
我得到:
[19:38:02] jalal@echo:~/research/code$ docker pull docurdt/heal
Using default tag: latest
Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
答案1
这是我的 /etc/systemd/system/docker.service.d/http-proxy.conf 在安装 docker 之后:
[Service]
Environment="HTTP_PROXY=http://my.proxy.address:8080/"
我添加了 HTTPS_PROXY 变量,修复了连接问题:
[Service]
Environment="HTTP_PROXY=http://my.proxy.address:8080/"
Environment="HTTPS_PROXY=http://my.proxy.address:8080/"
因此,就你的情况而言,可能是:
[Service]
Environment="HTTP_PROXY=http://webproxy.bu.edu:8900/"
Environment="HTTPS_PROXY=http://webproxy.bu.edu:8900/"
答案2
$ sudo mkdir -p /etc/systemd/system/docker.service.d
$ sudo vi /etc/systemd/system/docker.service.d/http-proxy.conf
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker
$ docker pull docurdt/heal
Using default tag: latest
latest: Pulling from docurdt/heal
e79bb959ec00: Pull complete
7dc808d5d247: Pull complete
04e0dd83f1c1: Pull complete
7680ea831bfd: Pull complete
f861c2ba948a: Pull complete
27ae46f94ae6: Pull complete
92a8fc1df4e5: Pull complete
d6ff073d4a06: Pull complete
626ee3046583: Pull complete
Digest: sha256:31f30cf69b3271fffcba4c439ee19c92587969cd74ec649ec72dec84ce177b86
Status: Downloaded newer image for docurdt/heal:latest
docker.io/docurdt/heal:latest
这是我在 http-proxy.conf 中的内容:
$ cat /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://webproxy.bu.edu:8900"
Environment="HTTPS_PROXY="http://webproxy.bu.edu:8900"
非常感谢 IRC 的 twainwek 抽出时间并与我分享此链接https://github.com/docker/for-win/issues/1534#issuecomment-405903684
答案3
脚步:
- 删除 resolvconf 包并手动管理 /etc/resolv.conf
sudo apt purge resolvconf
- 删除 /etc/resolv.conf
sudo rm /etc/resolv.conf
- 如果不存在则创建文件
touch /etc/resolv.conf
- 编辑文件:
nano /etc/resolv.conf
并添加以下内容:
nameserver 8.8.4.4
nameserver 8.8.8.8
- 就这样。现在,你可以拉取你的 docker 了。
答案4
我遇到了同样的错误。我使用的是 Ubuntu 20.04 系统
Error response from daemon: Get "https://registry-1.docker.io/v2/": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
我添加了里面缺失的行/etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4
sudo nano /etc/resolv.conf
现在的情况就是这样。
nameserver 8.8.8.8
nameserver 8.8.4.4
nameserver 127.0.0.53
options edns0 trust-ad