Skip to content

Docker代理配置

config http-proxy.conf

shell
sudo mkdir /etc/systemd/system/docker.service.d

cat <<EOF | sudo tee /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://127.0.0.1:1080"
Environment="HTTPS_PROXY=http://127.0.0.1:1080"
Environment="NO_PROXY=localhost,127.0.0.1"
EOF

sudo systemctl daemon-reload
sudo systemctl restart docker

docker info

config daemon.json

shell
cat <<EOF | sudo tee /etc/docker/daemon.json
{
  "registry-mirrors": [
    "https://docker.mirrors.ustc.edu.cn"
  ],
  "http-proxy": "http://127.0.0.1:1080",
  "https-proxy": "http://127.0.0.1:1080",
  "no-proxy": "localhost,127.0.0.1"
}
EOF

jq . /etc/docker/daemon.json
sudo dockerd --config-file=/etc/docker/daemon.json --validate

systemctl daemon-reload && systemctl restart docker

docker proxy config

shell
sudo bash
apt install -y docker.io docker-compose make

cat <<EOF | sudo tee /etc/docker/daemon.json
{
  "registry-mirrors": [
    "https://docker.m.daocloud.io",
    "https://dockerproxy.com",
    "https://docker.mirrors.ustc.edu.cn",
    "https://docker.nju.edu.cn",
    "https://docker.1panel.live"
  ]
}
EOF

systemctl daemon-reload && systemctl restart docker

Released under the MIT License.