更新时间:2023-02-01 08:39:27
我做了更多的研究,并且似乎使用了更好的关键词,因为我现在找到了解决方案。我想与所有人共享该解决方案,以防其他人可能需要它。
I did a bit more research and seem to have used better key words because I found my solution now. I wanted to share the solution with everyone, in case someone else may ever need it.
创建用于通过systemd配置docker服务的文件夹
Create folder for configuring docker service through systemd
mkdir /etc/systemd/system/docker.service.d
在 /etc/systemd/system/docker.service.d/http-proxy.conf
中创建服务配置文件,并将以下内容放入新创建的文件
Create service configuration file at /etc/systemd/system/docker.service.d/http-proxy.conf
and put the following in the newly created file
[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
# For Proxy server which require username and password authentication, just add the proper username and password to the URL. (see example below)
# Example without authentication
Environment="HTTP_PROXY=http://proxy_url:proxy_port" "NO_PROXY=localhost,127.0.0.0/8"
# Example with authentication
Environment="HTTP_PROXY=http://username:password@proxy_url:proxy_port" "NO_PROXY=localhost,127.0.0.0/8"
重新加载systemctl以便读取新设置
Reload systemctl so that new settings are read
sudo systemctl daemon-reload
验证docker服务环境是否为正确设置
Verify that docker service Environment is properly set
sudo systemctl show docker --property Environment
重新启动docker服务,使其使用更新的环境设置
Restart docker service so that it uses updated Environment settings
sudo systemctl重新启动docker
现在,您可以在计算机上执行 docker-compose
命令,而无需获取任何连接被拒绝
错误消息。
Now you can execute the docker-compose
command on your machine without getting any connection refused
error messages.