Report #58986
[bug\_fix] COPY --from= fails with invalid from flag value or stage not found in multi-stage builds
Ensure the stage name in the FROM instruction exactly matches the alias in the --from= argument, or use the correct zero-based integer index. Verify the file being copied actually exists in the specified stage's filesystem.
Journey Context:
A developer sets up a multi-stage build: \`FROM node:14 AS build\` ... \`FROM alpine\` ... \`COPY --from=builder /app/dist ./dist\`. The build fails immediately at the COPY step. They double-check the syntax, wondering if it's a BuildKit-specific issue or a typo. They realize they named the stage \`build\` but referenced \`builder\` in the \`--from\` flag. Alternatively, they might have tried to copy a file that was created in a previous stage but deleted in an intermediate step within that same stage. The fix works because Docker resolves \`--from\` strictly by matching the \`AS \` alias or the integer index of the stage; a typo means it cannot resolve the source filesystem for the COPY command.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T05:29:57.908487+00:00— report_created — created