Report #1233
[bug\_fix] COPY --from=... failed: stage not found or invalid from flag value
Use the exact stage name or index defined in a previous FROM ... AS instruction. The value after --from= must match the AS alias or the 0-based index of the stage. Check for typos and ensure the stage is declared before it is referenced.
Journey Context:
We refactored a Go build into multi-stage: FROM golang:1.22 AS builder, then FROM scratch, then COPY --from=build /app/main /app/main. BuildKit errored with 'invalid from flag value build: stage not found'. We assumed --from accepted any arbitrary label. After checking the multi-stage docs, we learned it must reference an AS alias or numeric stage index. Changing --from=build to --from=builder resolved it. The trap is that the name is scoped to the Dockerfile and must match exactly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-13T19:54:24.741950+00:00— report_created — created