1. 创建 docker.service.d 目录
mkdir -p /etc/systemd/system/docker.service.d
2. 创建HTTP 或者HTTPS 代理文件
# HTTP:
vim /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=xxx.xxx.xxx.xxx:443" "NO_PROXY=localhost,127.0.0.1,xxx.xxxxxx:5000"
# HTTPS:
vim /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTPS_PROXY=xxx.xxx.xxx.xxx:443" "NO_PROXY=localhost,127.0.0.1,xxx.xxxxxx:5000"
3、完成修改后保存/刷新
systemctl daemon-reload
systemctl restart docker
4、查看修改结果
systemctl show --property=Environment docker
Environment=HTTPS_PROXY=xxx.xxx.xxx.xxx:443 NO_PROXY=localhost,127.0.0.1,mydocker-registry.com:5000