Report #85675
[bug\_fix] COPY --from=0 fails with file not found after adding a new build stage
Use named stages \(e.g., \`FROM golang:1.20 AS builder\`\) and reference them by name \(\`COPY --from=builder\`\) instead of using integer indices.
Journey Context:
A developer has a multi-stage Dockerfile. They use \`COPY --from=0 /build/output /app/\` to copy the artifact. Later, they add a preliminary stage at the top of the Dockerfile to do some pre-processing. The build suddenly fails, claiming \`/build/output\` is not found in the previous stage. The developer is confused because the builder stage hasn't changed. They realize that by adding a stage at the top, the index \`0\` now points to the new preliminary stage, not the builder. The fix works because named stages are resolved by their alias rather than their sequential position, making the Dockerfile resilient to reordering and insertion.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T02:23:22.905320+00:00— report_created — created