跳到主要内容

docker pull 设置代理

阅读需 1 分钟

删除旧镜像服务器文件

sudo mv /etc/docker/daemon.json /etc/docker/daemon.json.bak.20240609

Docker d 开启代理

sudo mkdir -p /etc/systemd/system/docker.service.d
sudo touch /etc/systemd/system/docker.service.d/proxy.conf
sudo vim /etc/systemd/system/docker.service.d/proxy.conf

# Add content below
[Service]
Environment="HTTP_PROXY=http://127.0.0.1:7890/"
Environment="HTTPS_PROXY=http://127.0.0.1:7890/"
Environment="NO_PROXY=localhost,127.0.0.1,.example.com"

# 重启Docker
sudo systemctl daemon-reload && sudo systemctl restart docker

# 检查Docker有没有使用VPN
systemctl show --property=Environment docker
# Environment=HTTP_PROXY=http://127.0.0.1:7890 HTTPS_PROXY=http://127.0.0.1:7890
Loading Comments...