How to make a build arg mandatory during Docker build?

后端 未结 6 1947
后悔当初
后悔当初 2020-12-23 16:15

Is there any way to make a build argument mandatory during docker build? The expected behaviour would be for the build to fail if the argument is missing.

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

    I tested with RUN test -n what @konradstrack mentioned in the original (edit) post... that seems do the job of mandating the variable to be passed as the build time argument for the docker build command:

    FROM ubuntu
    
    ARG MY_VARIABLE
    RUN test -n "$MY_VARIABLE"
    ENV MY_VARIABLE $MY_VARIABLE
    

提交回复
热议问题