Dockerfile - 将 ENV 设置为命令的结果 [英] Dockerfile - set ENV to result of command
本文介绍了Dockerfile - 将 ENV 设置为命令的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以将 docker ENV 变量设置为命令的结果?喜欢:
Is it possible to set a docker ENV variable to the result of a command? Like:
ENV MY_VAR whoami
我希望 MY_VAR 获得值root"或 whoami 返回的任何值
i want MY_VAR to get the value "root" or whatever whoami returns
推荐答案
作为 DarkSideF 答案的补充.
As an addition to DarkSideF answer.
您应该知道 Dockerfile 中的每一行/命令都在另一个容器中运行.
You should be aware that each line/command in Dockerfile is ran in another container.
你可以这样做:
RUN export bleah=$(hostname -f);echo $bleah;
这是在单个容器中运行的.
This is run in a single container.
这篇关于Dockerfile - 将 ENV 设置为命令的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文