Report #3179
[bug\_fix] Build arg appears empty or uses the wrong value inside a build stage even though it was set before FROM or passed with --build-arg.
Re-declare the ARG inside the stage that needs it. Put \`ARG NODE\_VERSION\` after the \`FROM\` line \(with no value to inherit the global default, or with a default\). ARGs defined before FROM are only in scope for FROM lines; each FROM starts a new stage that does not inherit earlier ARGs.
Journey Context:
You set \`ARG NODE\_VERSION=20\` at the top of the Dockerfile and use \`FROM node:$\{NODE\_VERSION\}\`, then later \`RUN node --version\` expecting 20. It prints the base image's default instead, and passing \`--build-arg NODE\_VERSION=18\` only changes the FROM tag. Re-reading the Dockerfile reference shows that an ARG before FROM is outside any build stage; each FROM resets the variable namespace. Adding \`ARG NODE\_VERSION\` immediately after FROM wires the build argument into that stage.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T15:38:44.529652+00:00— report_created — created