创建 Docker 代理配置文件:
mkdir -p /etc/systemd/system/docker.service.d nano /etc/systemd/system/docker.service.d/proxy.conf
添加以下内容(根据你的代理信息调整):
[Service] Environment="HTTP_PROXY=socks5://172.16.0.3:1070" Environment="HTTPS_PROXY=socks5://172.16.0.3:1070" Environment="NO_PROXY=localhost,127.0.0.1,::1,172.18.0.1/16"
重载并重启 Docker 服务:
systemctl daemon-reload systemctl restart docker
验证代理是否生效:
docker info | grep -i proxy
如果代理配置已生效,你会看到类似以下的输出:
HTTP Proxy: socks5://172.16.0.3:1070
HTTPS Proxy: socks5://172.16.0.3:1070
No Proxy: localhost,127.0.0.1,::1,172.18.0.1/16