docker proxy 【docker 代理】-LMLPHP

第一种

创建代理配置文件

mkdir -p  /etc/systemd/system/docker.service.d/
cat <<EOF >  /etc/systemd/system/docker.service.d/http-proxy.conf
Environment="HTTP_PROXY=http://192.168.21.101:7890"
Environment="HTTPS_PROXY=http://192.168.21.101:7890"
Environment="NO_PROXY=localhost,127.0.0.1,.coding.net,.tencentyun.com,.myqcloud.com,harbor.bsgchina.com"
EOF

重启docker

systemctl daemon-reload && systemctl restart docker && systemctl status docker

测试

$ docker pull registry.k8s.io/pause:3.9
3.9: Pulling from pause
Digest: sha256:7031c1b283388d2c2e09b57badb803c05ebed362dc88d84b480cc47f72a21097
Status: Image is up to date for registry.k8s.io/pause:3.9
registry.k8s.io/pause:3.9

第二种

mkdir -p /usr/lib/systemd/system/docker.service.d
cat /usr/lib/systemd/system/docker.service.d/http-proxy.conf 
Environment="HTTP_PROXY=http://192.168.10.105:7890"
Environment="HTTPS_PROXY=http://192.168.10.105:7890"
Environment="NO_PROXY=localhost,127.0.0.1,.coding.net,.tencentyun.com,.myqcloud.com,harbor.bsgchina.com"

重启docker

systemctl daemon-reload && systemctl restart docker && systemctl status docker

测试

$ docker pull registry.k8s.io/pause:3.9
3.9: Pulling from pause
Digest: sha256:7031c1b283388d2c2e09b57badb803c05ebed362dc88d84b480cc47f72a21097
Status: Image is up to date for registry.k8s.io/pause:3.9
registry.k8s.io/pause:3.9
02-05 19:14