我做了一些研究,似乎使用了更好的关键词,因为我现在找到了解决方案。我希望与所有人分享解决方案,以防其他人可能需要它。
mkdir /etc/systemd/system/docker.service.d
/etc/systemd/system/docker.service.d/http-proxy.conf
[Service] # NO_PROXY is optional and can be removed if not needed # Change proxy_url to your proxy IP or FQDN and proxy_port to your proxy port Environment="HTTP_PROXY=http://proxy_url:proxy_port" "NO_PROXY=localhost,127.0.0.0/8"
重新加载systemctl以便读取新设置
sudo systemctl daemon-reload
验证是否正确设置了docker service Environment
sudo systemctl show docker --property Environment
重新启动docker服务,以便它使用更新的环境设置
sudo systemctl restart docker
现在你可以执行了 docker-compose 你的机器上没有任何命令 connection refused 错误消息。
docker-compose
connection refused