todaygood / container-lab

for docker
0 stars 0 forks source link

docker pull 设置代理还是失败 #10

Open todaygood opened 5 years ago

todaygood commented 5 years ago

按照文档,在命令行 export http_proxy="http://127.0.0.1:1080" export https_proxy="http://127.0.0.1:1080" export no_proxy="*.cn"

然后 [root@centos1 bin]# docker pull k8s.gcr.io/kube-addon-manager:v8.6 Error response from daemon: Get https://k8s.gcr.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

报错,根本就没有用到代理, 因为测试 curl -kv https://www.facebook.com/ 是ok的。

todaygood commented 5 years ago

solution

添加环境变量到dockerd中

[root@centos1 bin]# vim /usr/lib/systemd/system/docker.service

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
Environment="HTTP_PROXY=http://127.0.0.1:1080/" "HTTPS_PROXY=https://127.0.0.1:1080/" "NO_PROXY=localhost,127.0.0.1,*.cn"
ExecStart=/usr/bin/dockerd

test 发现解决

[root@centos1 bin]# docker pull k8s.gcr.io/kube-addon-manager:v8.6
v8.6: Pulling from kube-addon-manager
ff3a5c916c92: Downloading [======================>                            ]  926.9kB/2.066MB
c79820e57595: Downloading [================================================>  ]  2.046MB/2.115MB
36d39e631a7f: Download complete 
a3f1f3a57b4c: Download complete