我从ubuntu virtualbox中的docker运行以下命令,并得到一个连接被拒绝的错误。
我在一个公司代理后面,并且已经将我的环境变量配置为使用代理、用户名和密码。我还尝试使用代理链。
root@mbak1-VirtualBox:~# sudo proxychains docker pull busybox
ProxyChains-3.1 (http://proxychains.sf.net)
Using default tag: latest
Error response from daemon: Get https://registry-1.docker.io/v2/: dial tcp 54.152.209.167:443: getsockopt: connection refused
root@mbak1-VirtualBox:~# docker pull hello-world
Using default tag: latest
Error response from daemon: Get https://registry-1.docker.io/v2/: dial tcp 35.169.231.249:443: getsockopt: connection refused我的情况似乎与以下情况完全相同:
https://github.com/moby/moby/issues/31510
更新
我尝试将我的代理配置添加到以下文件中,但它不起作用。此外,该文件不存在: /etc/sysconfig/docker。
我还试图访问实际的URL,但得到的JSON响应显示未授权。

update2
我想问题出在我的DNS配置上。在虚拟机中,我获得了以下内容以进行查找:
mbak1@mbak1-VirtualBox:~$ nslookup registry-1.docker.io
Server: 127.0.0.1
Address: 127.0.0.1#53
Non-authoritative answer:
Name: registry-1.docker.io
Address: 34.200.28.105
Name: registry-1.docker.io
Address: 52.54.216.153
Name: registry-1.docker.io
Address: 34.200.90.16
Name: registry-1.docker.io
Address: 52.204.202.231
Name: registry-1.docker.io
Address: 52.22.181.254
Name: registry-1.docker.io
Address: 54.152.209.167
Name: registry-1.docker.io
Address: 34.205.207.96
Name: registry-1.docker.io
Address: 35.169.231.249发布于 2018-05-02 18:13:06
我的问题的答案来自这里的这篇文章:https://community.ubnt.com/t5/UNMS-Beta/Connection-Refused-Failed-to-pull-docker-images/m-p/2220235/highlight/true#M3960
我正在转载它:
我设法找到了一个解决方案,为docker添加了一个代理。谢谢你的帮助。
为docker服务创建systemd插件目录:
$ sudo mkdir -p /etc/systemd/system/docker.service.d
创建添加HTTP_PROXY环境变量的名为/etc/systemd/system/docker.service.d/http-proxy.conf的文件:
[Service]
Environment="HTTP_PROXY=http://proxy.example.com:80/"或者,如果您使用的是HTTPS代理服务器,请创建添加HTTPS_PROXY环境变量的名为/etc/systemd/system/docker.service.d/https-proxy.conf的文件:
[Service]
Environment="HTTPS_PROXY=https://proxy.example.com:443/"如果您有内部Docker注册表,您需要在没有代理的情况下联系它们,您可以通过NO_PROXY环境变量指定它们:
[Service]
Environment="HTTP_PROXY=http://proxy.example.com:80/" "NO_PROXY=localhost,127.0.0.1,docker-registry.somecorporation.com"或者,如果您使用HTTPS代理服务器:
[Service]
Environment="HTTPS_PROXY=https://proxy.example.com:443/" "NO_PROXY=localhost,127.0.0.1,docker registry.somecorporation.com"刷新更改:
sudo systemctl daemon-reload
重启Docker:
sudo systemctl restart docker
验证配置是否已加载:
systemctl show --property=Environment docker
Environment=HTTP_PROXY=http://proxy.example.com:80/
或者,如果您使用HTTPS代理服务器:
systemctl show --property=Environment docker
Environment=HTTPS_PROXY=https://proxy.example.com:443/
https://stackoverflow.com/questions/50130899
复制相似问题