0
点赞
收藏
分享

微信扫一扫

dockerfile 中 ARG与ENV的区别

The

ARG

instruction defines a variable that users can pass at build-time to the builder with the docker build command using the

--build-arg <varname>=<value>

flag.ARG指令定义了用户可以在编译时或者运行时传递的变量,如使用如下命令:

--build-arg <varname>=<value>

The

ENV

instruction sets the environment variable

<key>

to the value

<value>

.

The environment variables set using

ENV

will persist when a container is run from the resulting image.ENV指令是在dockerfile里面设置环境变量,不能在编译时或运行时传递。


以下是ARG和ENV的有效结合:




ARG var
ENV var=${var}




You can then either build an image with a specific 
var
 value at build-time (
docker build --build-arg var=xxx
), or run a container with a specific runtime value (
docker run -e var=yyy
)






举报

相关推荐

0 条评论