Report #102391
[bug\_fix] Multi-stage build fails with 'COPY --from=stageName: no stage found' or copies unexpected files
Ensure the name used in \`COPY --from=\` exactly matches an \`AS \` stage declared earlier, or use the numeric index of the stage. Remember that an intermediate stage only exists if it is referenced by a later stage or is the final stage; otherwise it may be pruned.
Journey Context:
I was trying to shrink a Go image with a builder pattern. I had \`FROM golang:1.22 AS builder\` and later \`COPY --from=build /app/myapp /usr/local/bin/\`. The build failed with 'no stage found with name build'. I had renamed the stage to 'builder' but forgot to update the COPY. Then I tried \`COPY --from=0\` and it worked because 0 is the first stage index. Another time I had a typo in AS \(\`AS bulder\`\) and COPY --from=builder could not find it. The error is literal: BuildKit/Docker resolves --from against stage names at parse time, not filesystem paths. The fix is either consistent naming or using zero-based indices.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-09T04:47:54.044845+00:00— report_created — created