Docker网络代理配置

1. 创建目录

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

2. 创建http-proxy.conf文件,增加以下内容

cat > /etc/systemd/system/docker.service.d/http-proxy.conf <"HTTP_PROXY=http://192.168.0.2:8118"
Environment="HTTPS_PROXY=http://192.168.0.2:8118"
Environment="NO_PROXY=localhost,127.0.0.1,registry.onlymin.com,reg.onlymin.com"
EOF

3. Daemon重新reload 并重启docker

systemctl daemon-reload
systemctl restart docker

4. 检查变量是否加载

systemctl show docker --property Environment

5. 取消代理

rm  /etc/systemd/system/docker.service.d/http-proxy.conf -rf
systemctl daemon-reload
systemctl restart docker
systemctl show docker --property Environment

你可能感兴趣的:(Docker)