如何给docker设置http代理
公司网络使用代理服务器上外网。在ubuntu上用docker pull出现错误
1 | sudo docker pull busybox |
但是我明明已经为ubuntu设置了http_proxy了。
查了试了半天,才知道还需要给docker单独设代理,以下是步骤。
First, create a systemd drop-in directory for the docker service:
1 | mkdir /etc/systemd/system/docker.service.d |
Now create a file called /etc/systemd/system/docker.service.d/http-proxy.conf that adds the HTTP_PROXY environment variable:
1 | [Service] |
If you have internal Docker registries that you need to contact without proxying you can specify them via the NO_PROXY environment variable:
1 | Environment="HTTP_PROXY=http://proxy.example.com:80/" |
Flush changes:
1 | sudo systemctl daemon-reload |
Verify that the configuration has been loaded:
1 | sudo systemctl show docker --property Environment |
Restart Docker:
1 | sudo systemctl restart docker |
现在好使了。
1 | sudo docker pull busybox |
原文链接 https://blog.csdn.net/chang_harry/article/details/52116305?utm_source=blogxgwz2
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 轨 道 兔!
评论
