Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Linux Docker无法加载代理环境变量_Linux_Docker_Centos7 - Fatal编程技术网

Linux Docker无法加载代理环境变量

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

我在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=<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.