How to define a variable in a Dockerfile?

后端 未结 6 1213
情歌与酒
情歌与酒 2020-12-07 16:02

In my Dockerfile, I would like to define variables that I can use later in the Dockerfile.

I am aware of the

6条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-07 16:41

    You can use ARG variable defaultValue and during the run command you can even update this value using --build-arg variable=value. To use these variables in the docker file you can refer them as $variable in run command.

    Note: These variables would be available for Linux commands like RUN echo $variable and they wouldn't persist in the image.

提交回复
热议问题