一、添加环境变量
vim ~/.bashrc
#添加这两行
export http_proxy="http://proxy.example.com:port"
export https_proxy="http://proxy.example.com:port"
#注意修改为你的代理配置,一般https_proxy的配置需要写成http://......,否则可能报错
source ~/.bashrc
二、在docker中配置
sudo mkdir -p /etc/systemd/system/docker.service.d
sudo vim /etc/systemd/system/docker.service.d/http-proxy.conf
#添加以下内容,同样注意HTTPS_PROXY=http://proxy.example.com:port写成http开头。
[Service]
Environment="HTTP_PROXY=http://proxy.example.com:port"
Environment="HTTPS_PROXY=http://proxy.example.com:port"
Environment="NO_PROXY=localhost,127.0.0.1"
重启docker
sudo systemctl daemon-reload
sudo systemctl restart docker
测试拉取镜像
docker pull xxx
标签:http,拉取,proxy,example,镜像,docker,com,port
From: https://www.cnblogs.com/ejjw/p/18375229