1、注意Docker版本(此处版本为docker-ce-18.06.1)
docker version
2、编辑Docker服务配置文件
vim /usr/lib/systemd/system/docker.service
......
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
Environment="HTTPS_PROXY=http://172.16.16.100:1080"
Environment="NO_PROXY=127.0.0.0/8,172.16.16.0/21"
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
......
3、重启Docker服务
systemctl daemon-reload
systemctl restart docker
4、验证代理设置
docker info
参考:
https://docs.docker.com/config/daemon/systemd/