Report #99613
[bug\_fix] Multi-stage build fails with 'failed to solve: stage not found' or COPY --from references the wrong stage
Name every stage with \`FROM ... AS \` and use that exact name in \`COPY --from=\`. If using numeric indexes, remember they are zero-based in order of appearance. Avoid copying from a stage defined after the current one.
Journey Context:
A Go developer writes a Dockerfile with \`FROM golang:1.22 AS builder\`, then later \`FROM alpine\` and \`COPY --from=build /bin/app /app\`. BuildKit errors with 'stage not found'. They hunt through the file for a missing FROM, not noticing the typo \`build\` versus \`builder\`. After naming stages explicitly they also learn that numeric indexes count every \`FROM\` starting at 0, so \`COPY --from=0\` can silently break when a new stage is inserted. Switching to named stages makes the Dockerfile self-documenting and prevents both the typo and reordering hazards.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-30T04:45:52.534896+00:00— report_created — created