Docker通过代理

时间:2017-08-10 14:49:32

标签: docker proxy

我确实在CLI设置了一个代理如下:

$ export http_proxy="http://10.20.6.67:1209"
$ export https_proxy="https://10.20.6.67:1209"
$ export no_proxy="localhost,127.0.0.1,0.0.0.0"

我正在尝试从Docker中提取图像,但它返回以下错误:

$ docker pull couchdb
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 个答案:

答案 0 :(得分:3)

我按 Control Docker with systemd, HTTP/HTTPS proxy 中所述解决了这个问题。

创建一个名为 /etc/systemd/system/docker.service.d/http-proxy.conf 的文件,该文件添加了HTTP_PROXY环境变量:

[Service]
Environment="HTTP_PROXY=http://proxy.example.com:80/" "NO_PROXY=localhost,127.0.0.1,docker-registry.somecorporation.com"

刷新更改:

$ sudo systemctl daemon-reload

重启Docker:

$ sudo systemctl restart docker

现在docker pull有效!