Is there a way to print ARG
s values, that are passed via the --build-arg
flags to a docker build
command?
Just using RUN echo $ARG_NAME
isn't enough since I want it to be printed before the FROM
section, where it's not allowed.
The point is to see these values immediately so I can stop the build quickly, preventing downloading the wrong base images.
Already searched docker docs and google. Maybe someone here can shed some light.
You could use a multi-stage build where the first stage is just for diagnostics and otherwise gets completely ignored.
FROM busybox
ARG ARG_NAME
RUN echo $ARG_NAME
FROM python:3.8
ARG ARG_NAME
...
CMD ["my_app"]
Note that Docker layer caching can cause RUN
steps to be totally skipped so even this isn't 100% reliable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With