Skip to content

CenOS7配置DockerSocket代理

启用代理

shell
mkdir /etc/systemd/system/docker.service.d/ 
cat << /etc/systemd/system/docker.service.d/http-proxy.conf > EOF
[Service]
Environment="HTTP_PROXY=代理服务器IP地址:http协议端口"
Environment="HTTPS_PROXY=代理服务器IP地址:http协议端口"
Environment="NO_PROXY=localhost,127.0.0.1,easzlab.io.local"
EOF
systemctl daemon-reload
systemctl restart docker
service network restart

关闭代理

shell
cat << /etc/systemd/system/docker.service.d/http-proxy.conf > EOF
[Service]
#Environment="HTTP_PROXY=代理服务器IP地址:端口"
#Environment="HTTPS_PROXY=代理服务器IP地址:端口"
#Environment="NO_PROXY=localhost,127.0.0.1,easzlab.io.local"
EOF
systemctl daemon-reload
systemctl restart docker
service network restart