Report #418
[bug\_fix] ARG value defined before FROM is not available in build stages
Re-declare the ARG inside each build stage that needs it: \`ARG NODE\_VERSION\` after each \`FROM\`. ARG declared before the first FROM is only valid for FROM lines, not RUN/COPY/ENV inside stages.
Journey Context:
You set \`ARG NODE\_VERSION=20\` at the top of the Dockerfile and use \`FROM node:$\{NODE\_VERSION\}\` successfully, but later \`RUN node --version\` prints the wrong Node or an expansion shows blank. You grep docs and learn that each \`FROM\` starts a fresh build stage and resets the ARG scope. The ARG at the top only scopes to FROM instructions. You add \`ARG NODE\_VERSION\` right after each \`FROM\` that needs it, and the variable propagates correctly. This is a classic silent failure because the FROM expansion works, making you think the ARG is global.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-13T07:54:18.725881+00:00— report_created — created