1. 程式人生 > >dockerfile 中 ARG與ENV的區別

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)   歡迎關注橙子部落格微信公眾號:chengziboke888 qrcode_for_gh_92c9913f785a_258

檢視原文:http://zccbbg.top/2017/06/19/dockerfile-%e4%b8%ad-arg%e4%b8%8eenv%e7%9a%84%e5%8c%ba%e5%88%ab/