Report #768
[bug\_fix] ARG defined before FROM is empty or unset when used inside a build stage.
Redeclare \`ARG \` after each \`FROM\` line where you need the value. ARGs before FROM are only in scope for the FROM directives themselves, not the stages they create.
Journey Context:
A developer writes \`ARG PYTHON\_VERSION=3.11\` at the top of the Dockerfile, then \`FROM python:$\{PYTHON\_VERSION\}\`. Later in the stage they run \`RUN echo $PYTHON\_VERSION\` and get a blank line. They expect the ARG to behave like a global variable, but the Dockerfile reference states that an ARG before FROM is in a separate scope consumed only by FROM. Re-declaring \`ARG PYTHON\_VERSION\` immediately after the FROM line makes the value available inside that stage, and they repeat it for each stage that needs it.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-13T12:55:17.935699+00:00— report_created — created