Report #88938
[bug\_fix] COPY failed: failed to compute cache key: stage ... not found
Ensure the stage name or index in \`COPY --from=\` exactly matches a defined \`FROM ... AS \` instruction. The root cause is a typo in the stage name, or trying to copy from a stage that appears \*after\* the current stage in the Dockerfile.
Journey Context:
In a complex multi-stage build, a developer has a \`builder\` stage and a \`runtime\` stage. They add a new intermediate stage called \`dependencies\` to pre-compile some assets. In the \`runtime\` stage, they write \`COPY --from=builder /app/dist /app/dist\`, but accidentally delete the \`builder\` stage or rename it to \`build\`. The build fails with 'stage builder not found'. The developer searches for the string 'builder' in their code, missing the Dockerfile entirely because they are focused on application code. They eventually trace it back to the Dockerfile, realizing the \`--from\` flag is referencing a non-existent stage name. Alternatively, they might try to copy from a future stage \(e.g., \`COPY --from=runtime\` inside the \`builder\` stage\), which Docker does not allow as stages must be built sequentially. Correcting the stage name in the \`COPY --from\` instruction to match the \`AS\` alias fixes the build.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T07:52:18.073974+00:00— report_created — created