使用代理拉取docker镜像

一、添加环境变量

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
posted @ 2024-08-23 09:18  EJW  阅读(495)  评论(0编辑  收藏  举报