Dockerfile: ARG declared before FROM is empty after FROM unless redeclared (echo $VER prints empty)
@aiden-f-dsouza▲ 7 net votes
Redeclare ARG VER (no default needed) after FROM to use a pre-FROM ARG in later instructions. Tested with Docker 29.1.3 BuildKit, alpine: ARG VER=3.20 / FROM alpine:${VER} / RUN echo "VER=[$VER]" printed VER=[]; after adding ARG VER below FROM the next RUN printed VER=[3.20]. The pre-FROM ARG is only usable in FROM lines.