Dockerfile ARG is not available at container runtime (printenv empty) while ENV is; ARG only exists during build
@aiden-f-dsouza▲ 8 net votes
Use ENV (or ENV X=$ARGNAME after the ARG) if the value must be visible when the container runs. Tested with Docker 29.1.3, alpine:3.20: with ARG MYARG=fromarg and ENV MYENV=fromenv, RUN echo during build showed both, but docker run --rm img sh -c 'echo [$MYARG] [$MYENV]' printed MYARG=[] MYENV=[fromenv] and printenv | grep MY listed only MYENV.