- 创建 Docker 服务配置文件:
sudo mkdir -p /etc/systemd/system/docker.service.d
sudo vim /etc/systemd/system/docker.service.d/http-proxy.conf
- 添加代理配置:
[Service]
Environment="HTTP_PROXY=http://<proxy-address>:<port>"
Environment="HTTPS_PROXY=http://<proxy-address>:<port>"
Environment="NO_PROXY=localhost,127.0.0.1"
- 重新加载并重启 Docker:
sudo systemctl daemon-reload
sudo systemctl restart docker
- 测试是否成功:
docker run hello-world