mkdir -p /etc/systemd/system/docker.service.d
vim /etc/systemd/system/docker.service.d/http-proxy.conf
编辑文件/etc/systemd/system/docker.service.d/http-proxy.conf,添加如下配置
[Service]
Environment="HTTP_PROXY=http://192.168.58.21:7890/"
Environment="HTTPS_PROXY=http://192.168.58.21:7890/"
Environment="NO_PROXY=localhost,192.168.58.21,.example.com"
其中192.168.58.21:7890是你的clash服务器的地址(需要clash上开启允许local对外服务)。
# 启动服务
systemctl daemon-reload
systemctl restart docker
注意:
clash服务器无认是在Windows还是Linux下,都需要设置防火墙规则。