Dockerfile - set ENV to result of command

后端 未结 6 1260
傲寒
傲寒 2020-12-02 15:17

Is it possible to set a docker ENV variable to the result of a command? Like:

ENV MY_VAR whoami

i want MY_VAR to get the value \"root\" or

6条回答
  •  时光说笑
    2020-12-02 15:48

    As an addition to DarkSideF answer.

    You should be aware that each line/command in Dockerfile is ran in another container.

    You can do something like this:

    RUN export bleah=$(hostname -f);echo $bleah;
    

    This is run in a single container.

提交回复
热议问题