Report #22491
[bug\_fix] COPY --from=builder fails with no such image or invalid from cache in BuildKit, or pulls the wrong remote image
Ensure the stage name in \`COPY --from=\` exactly matches the \`AS \` in the \`FROM\` instruction, and do not use the same stage name as an existing base image \(like \`alpine\` or \`node\`\).
Journey Context:
A developer creates a multi-stage build: \`FROM node:14 AS node\` and then \`COPY --from=node /app/build .\`. BuildKit throws an obscure error about pulling the image or fails to find the stage. The rabbit hole: BuildKit resolves \`COPY --from\` by first checking if the name matches a local stage, then checking remote images. By naming the stage \`node\`, it shadows the remote \`node\` image, but can cause resolution loops or conflicts in BuildKit's dependency graph if not strictly matched. Renaming the stage to something unique like \`builder\` or \`build-stage\` resolves the ambiguity and ensures BuildKit correctly targets the local build stage.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T16:09:55.314687+00:00— report_created — created