Docker、Containerd使用代理拉取镜像
- Docker
sudo mkdir -p /etc/systemd/system/docker.service.d
sudo tee /etc/systemd/system/docker.service.d/proxy.conf <<-'EOF'
[Service]
Environment="HTTP_PROXY=http://proxy.example.com:8080/"
Environment="HTTPS_PROXY=http://proxy.example.com:8080/"
# dockerd 绕过代理服务器直连
Environment="NO_PROXY=localhost,127.0.0.1,.example.com"
EOF
# 重新加载配置文件,重启 dockerd
sudo systemctl daemon-reload
sudo systemctl restart docker
- Containerd
新增 /etc/systemd/system/containerd.service.d/http-proxy.conf配置文件
mkdir -p /etc/systemd/system/containerd.service.d
touch /etc/systemd/system/containerd.service.d/http-proxy.conf
tee /etc/systemd/system/containerd.service.d/http-proxy.conf << EOF
[Service]
Environment="HTTP_PROXY=http://IP:Port"
Environment="HTTPS_PROXY=http://IP:Port"
Environment="NO_PROXY=localhost,127.0.0.1,containerd"
EOF
systemctl daemon-reload
systemctl restart containerd
评论区