公司内部使用代理上网,docker默认是无法通过代理上网的,即使在你的系统内已经设置了代理的环境变量,操作系统可以通过 代理上网,但docker不行,需要给docker添加代理地址
[root@resiones ~]# docker pull hello-world
Unable to find image 'hello-world:latest' locally
Pulling repository docker.io/library/hello-world
docker: Network timed out while trying to connect to https://index.docker.io/v1/repositories/library/hello-world/images.
You may want to check your internet connection or if you are behind a proxy..
一、设置代理:
[root@resiones ~]# mkdir -p /etc/systemd/system/docker.service.d
[root@resiones ~]# vi /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://xx.xx.xx.xx:80/“
Environment="HTTPS_PROXY=http://xx.xx.xx.xx:80/”
Environment="NO_PROXY=localhost,127.0.0.0/8,10.10.10.10"
二、重启docker
[root@resiones ~] systemctl daemon-reload
[root@resiones ~] systemctl restart docker
三、查看配置结果
[root@resiones ~] systemctl show --property=Environment docker