Linux · 7 1 月, 2021 0

为docker设置代理

  1. 创建配置目录
    mkdir /etc/systemd/system/docker.service.d

  2. 添加地址

cd /etc/systemd/system/docker.service.d
cat >/etc/systemd/system/docker.service.d/http_proxy.conf << EOF
[Service]
Environment="HTTP_PROXY=http://192.168.1.1:80/"
Environment="HTTPS_PROXY=http://192.168.1.1:80/"
Environment="NO_PROXY=localhost,127.0.0.0/8,docker-registry.somecorporation.com"
EOF
  1. 重启服务
systemctl daemon-reload
systemctl restart docker