Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fail if --build-arg is not passed [duplicate]

I have this in a Dockerfile:

ARG aws_access_key_id
ARG aws_secret_access_key

even though I did not use any --build-arg options, it still built successfully, how can I make it fail if those arguments are missing?

like image 370
Alexander Mills Avatar asked Sep 01 '25 10:09

Alexander Mills


1 Answers

You can set some default values that will never be used and then test if those are the values. For example:

FROM alpine
ARG arg=NO_VALUE
RUN [ ! "${arg}" == "NO_VALUE" ]
like image 173
kichik Avatar answered Sep 04 '25 02:09

kichik