如何配置Docker网络代理

下载clash

wget https://github.com/Dreamacro/clash/releases/download/v1.13.0/clash-linux-amd64-v1.13.0.gz
gzip -d clash-linux-amd64-v1.13.0.gz
chmod +x clash-linux-amd64-v1.13.0
sudo mv clash-linux-amd64-v1.13.0  /usr/local/bin/clash

运行clash

clash

生成~/.config/clash/config.yaml配置文件,将自己的代理配置更新到这个文件中,再次运行clash

测试代理是否生效

curl -x http://localhost:7890 https://www.google.com

更新docker.service

更新/lib/systemd/system/docker.service配置文件

[Service]
Environment="HTTP_PROXY=http://127.0.0.1:7890"
Environment="HTTPS_PROXY=http://127.0.0.1:7890"

通过配置bash的http_proxy环境变量,不生效。

重启docker

sudo systemctl daemon-reload
sudo systemctl restart docker
posted @ 2023-02-09 16:40  ByteHandler  阅读(1435)  评论(0编辑  收藏  举报