创建/etc/systemd/system/docker.service.d/http-proxy.conf文件,并添加HTTP_PROXY、HTTPS_PROXY环境变量:
如果还有内部的不需要使用代理来访问的Docker registries,那么嗨需要制定NO_PROXY环境变量:
[Service]
Environment="HTTP_PROXY=http://1.1.1.1:3128" "HTTPS_PROXY=http://1.1.1.1:3128" "NO_PROXY=192.168.1.1,node1,node1.cluster.local,192.168.1.2,node2,node2.cluster.local,192.168.1.3,node3,node3.cluster.local"
执行如下命令,更新配置:
systemctl daemon-reload
注意,HTTPS_PROXY后的proxy url也是http开头,而不是https,否则会报错:
proxyconnect tcp: tls: oversized record received with length 20527
参考: