Report #3174
[bug\_fix] failed to solve: source stage could not be found: build \(or failed to compute cache key for a COPY --from path\)
Name the stage with \`AS\` and reference it exactly in \`COPY --from=\`. For example, \`FROM golang:1.24 AS build\` followed by \`COPY --from=build /bin/app /usr/local/bin/app\`. Avoid relying on numeric stage indexes after reordering, and make sure the stage is defined before the COPY \(or use an external image/named context reference\).
Journey Context:
You refactor a Dockerfile into multi-stage, adding \`FROM node:20 AS build\` and \`FROM nginx:alpine\`. Later you rename the first stage to \`builder\` but leave \`COPY --from=build /app/dist /usr/share/nginx/html\`. BuildKit reports it cannot find the source stage. Grepping the Dockerfile reveals the typo; aligning the alias with the \`--from\` reference lets the artifact copy correctly. The stage name is the only handle BuildKit has for cross-stage copies, so mismatches break the DAG.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T15:37:46.235702+00:00— report_created — created