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.
I cannot comment yet because I do not have 50 reputation, but I would like to add onto @Jan Nash's solution because I had a little difficulty getting it to work with my image.
If you copy/paste @Jan Nash's solution, it will work and spit out the error message that the build argument is not specified.
What I want to add
When I tried getting it to work on a CentOS 7 image (centos:7), Docker ran the RUN command without erroring out.
Solution
Ensure that you're executing the RUN command with the bash shell.
RUN ["/bin/bash", "-c", ": ${MYUID:?Build argument needs to be set and not null.}"]
I hope that helps for future incoming people. Otherwise, I believe @Jan Nash's solution is just brilliant.