有没有 Dockerfile Env Instruction 的替代方案?
Is there an alternative to Dockerfile Env Instruction?
在他们的官方网站 (https://docs.docker.com/reference/builder/#env) 中,Docker 支持声明:
The ENV instruction sets the environment variable to the value
. This value will be passed to all future RUN instructions.
This is functionally equivalent to prefixing the command with < key >=< value >
我试过了:
http_proxy=<PROXY> docker build .
然而,这似乎并没有带来与在 Docker 文件中添加 ENV http_proxy=< PROXY > 相同的效果。为什么???
This is functionally equivalent to prefixing the command with < key >=< value >
这并不意味着它与前缀 docker build
命令相同,因为它是在容器外部执行的命令。
这意味着使用 ENV 与在容器中 运行 添加前缀命令相同。
例如,等效的 运行 语句如下所示:
RUN http_proxy=<PROXY> curl https://www.google.com
或在容器内执行的等效命令(通过shell):
$ http_proxy=<PROXY> curl https://www.google.com
在他们的官方网站 (https://docs.docker.com/reference/builder/#env) 中,Docker 支持声明:
The ENV instruction sets the environment variable to the value . This value will be passed to all future RUN instructions. This is functionally equivalent to prefixing the command with < key >=< value >
我试过了:
http_proxy=<PROXY> docker build .
然而,这似乎并没有带来与在 Docker 文件中添加 ENV http_proxy=< PROXY > 相同的效果。为什么???
This is functionally equivalent to prefixing the command with < key >=< value >
这并不意味着它与前缀 docker build
命令相同,因为它是在容器外部执行的命令。
这意味着使用 ENV 与在容器中 运行 添加前缀命令相同。
例如,等效的 运行 语句如下所示:
RUN http_proxy=<PROXY> curl https://www.google.com
或在容器内执行的等效命令(通过shell):
$ http_proxy=<PROXY> curl https://www.google.com