分享知识,分享快乐

0%

Docker配置代理服务器

Docker配置代理服务器

背景环境说明

Docker环境安装在内网,只有一台公共的代理服务器能够上网,
一般的docker pull会无法下载镜像。

新配置了代理服务器squid。(搭建squid代理服务器这里不讲,参考另一篇文章。不建议使用nginx坐正向代理,处理不了https。)
操作系统: Redhat 7.5 X86
内核: 3.10.0-862.el7.x86_64/docker 18.09
代理服务器: 10.1.1.1:10000

修改DockerService文件

1
vi /usr/lib/systemd/system/docker.service

在[Service]下面添加:

1
2
3
[Service]
Environment="HTTP_PROXY=http://10.1.1.1:10000"
Environment="HTTPS_PROXY=https://proxy.example.com:443"

重启Docker服务

1
2
3
systemctl daemon-reload
systemctl rstart docker
systemctl enable docker

检查

docker info,可以看到http proxy设置成功。

1
2
3
4
5
6
Debug Mode (client): false
Debug Mode (server): false
HTTP Proxy: http://10.1.1.1:10000
Registry: https://index.docker.io/v1/
Labels:
Experimental: false