Linux Docker无法加载代理环境变量
我在CentOs 8上安装了Linux Docker无法加载代理环境变量,linux,docker,centos7,Linux,Docker,Centos7,我在CentOs 8上安装了Docker版本18.06.3-ce 我的系统位于防火墙后面,因此我尝试通过在/etc/systemd/system/docker.service.d中添加http proxy文件来编辑代理设置 [Service] Environment="HTTP_PROXY=http://my_proxy:port" Environment="HTTPS_PROXY=http://my_other_proxy:port" Environment="NO_PROXY=<ANO
Docker
版本18.06.3-ce
我的系统位于防火墙后面,因此我尝试通过在/etc/systemd/system/docker.service.d
中添加http proxy
文件来编辑代理设置
[Service]
Environment="HTTP_PROXY=http://my_proxy:port"
Environment="HTTPS_PROXY=http://my_other_proxy:port"
Environment="NO_PROXY=<ANOTHER_PROXY>"
[服务]
Environment=“HTTP\u代理=http://my_proxy:port"
Environment=“HTTPS\u代理=http://my_other_proxy:port"
Environment=“NO\u PROXY=”
但是,即使在systemctl后台程序重新加载
和systemctl重新启动docker
之后,环境设置似乎也没有生效
当我尝试
systemctl show--属性环境docker
我看到的只是
环境=
没有价值观或任何东西
我不熟悉
Linux
和Docker
,所以不知道为什么会出现这种情况。虽然代理地址本身可能无法工作,但我希望至少能在环境
属性中看到这些值。您应该使用.json文件而不是使用ENV vars来配置Docker客户端
文件:
您应该使用.json文件而不是使用ENV vars来配置Docker客户端 文件:
On the Docker client, create or edit the file ~/.docker/config.json in the home directory of the user which starts containers. Add JSON such as the following, substituting the type of proxy with httpsProxy or ftpProxy if necessary, and substituting the address and port of the proxy server. You can configure multiple proxy servers at the same time.
You can optionally exclude hosts or ranges from going through the proxy server by setting a noProxy key to one or more comma-separated IP addresses or hosts. Using the * character as a wildcard is supported, as shown in this example.
{
"proxies":
{
"default":
{
"httpProxy": "http://your_proxy:port",
"httpsProxy": "https://your_other_proxy:port",
"noProxy": "*.test.example.com,.example2.com"
}
}
}
Save the file.
When you create or start new containers, the environment variables are set automatically within the container.