Skip to the content.

docker 代理的方法

使用 aliyun 加速

{
  "registry-mirrors": [
    "https://hub-mirror.c.163.com",
    "https://mirror.baidubce.com"
  ]
,
"default-address-pools":
 [
 {"base":"10.10.0.0/16","size":24}
 ]
}

https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors 修改为:

sudo tee /etc/docker/daemon.json << 'EOF'
{
  "registry-mirrors": ["https://123213413421324.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

配置代理的方法

https://stackoverflow.com/questions/58841014/set-proxy-on-docker

实际上,这个也是可以工作的

mkdir -p /etc/systemd/system/docker.service.d
IP=192.168.31.76
cat << _EOF_ > /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://$IP:7897/"
Environment="HTTPS_PROXY=http://$IP:7897/"
_EOF_
sudo systemctl daemon-reload
sudo systemctl restart docker

这个配置了之后,然后这个测试,效率大概是 1M

docker pull fedora:43

这个才是正确的,来自于官方文档:

IP=192.168.31.76
cat << _EOF_ > .docker/config.json
{
 "proxies": {
   "default": {
     "httpProxy": "http://$IP:7897",
     "httpsProxy": "http://$IP:7897",
     "noProxy": "127.0.0.0/8"
   }
 }
}
_EOF_

podman

配置代理的方法: https://podman-desktop.io/docs/proxy

在 $HOME/.config/containers/containers.conf 中添加:

[engine]
env = ["http_proxy=http://192.168.31.76:7897", "https_proxy=http://192.168.31.76:7897"]

本站所有文章转发 CSDN 将按侵权追究法律责任,其它情况随意。