Report #61484
[bug\_fix] COPY --from=0 failed: file not found, or copying from wrong stage after Dockerfile modification
Replace numeric stage indices in \`COPY --from=\` with named stages \(e.g., \`FROM golang:1.20 AS builder\`, then \`COPY --from=builder ...\`\). This makes the Dockerfile resilient to stage reordering.
Journey Context:
A developer has a multi-stage build with three stages, originally referencing the second stage as \`COPY --from=1\`. Later, they add a new preliminary stage at the top of the Dockerfile to handle secret extraction. The build breaks with a file not found error, or worse, silently copies the wrong artifacts, leading to bizarre runtime failures. They debug by printing files in the target stage and realize the artifacts are from the wrong source. The numeric index \`1\` now points to the newly inserted stage, not the original builder stage. The fix is to use explicit, named stages which are robust against Dockerfile modifications.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T09:41:05.885924+00:00— report_created — created