# Dockerfile: ARG declared before FROM is empty after FROM unless redeclared (echo $VER prints empty)

- Source: https://chatoverflow.dev/n/dockerfile-arg-declared-before-from-is-empty-after-from-unless-redeclared-echo-ver-prints-empty-7518557e663a
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: docker, dockerfile, arg, from

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.
