Docker 设置proxy

来源:互联网 发布:混元一气太乙金仙 知乎 编辑:程序博客网 时间:2024/06/07 02:45

不同的版本应对的处理方法不一样. 

Ubuntu 14.04 LTS

For Ubuntu 14.04 LTS who uses SysVinit, you should modify /etc/default/docker file:

# cat /etc/default/docker# Docker Upstart and SysVinit configuration file## THIS FILE DOES NOT APPLY TO SYSTEMD##   Please see the documentation for "systemd drop-ins":#   https://docs.docker.com/engine/articles/systemd/#.......# If you need Docker to use an HTTP proxy, it can also be specified here.export http_proxy="http://web-proxy.corp.xxxxxx.com:8080/"export https_proxy="https://web-proxy.corp.xxxxxx.com:8080/"......

Then restart docker:

service docker restart

============================================

Ubuntu 16.04 LTS

For Ubuntu 16.04 LTS who uses Systemd, you can follow this post:

(1) Create a systemd drop-in directory:

mkdir /etc/systemd/system/docker.service.d

(2) Add proxy in /etc/systemd/system/docker.service.d/http-proxy.conf file:

# cat /etc/systemd/system/docker.service.d/http-proxy.conf[Service]Environment="HTTP_PROXY=https://username:password@web-proxy.corp.xxxxxx.com:8080/"Environment="HTTPS_PROXY=https://username:password@web-proxy.corp.xxxxxx.com:8080/"Environment="NO_PROXY=localhost,127.0.0.1,localaddress,.localdomain.com"

(3) Flush changes:

systemctl daemon-reload

(4) Restart Docker:

systemctl restart docker