Report #493
[bug\_fix] COPY --from=build /app/target/release/mybin /usr/local/bin/mybin fails with 'build: no such stage' or copies artifacts from the wrong stage
Name the stage explicitly with FROM AS , for example FROM rust:1.78 AS build, and reference exactly that name in COPY --from=build. Avoid numeric stage indexes in non-trivial Dockerfiles because they break when stages are reordered.
Journey Context:
We refactored a Dockerfile to add a debug stage before the compiler stage. COPY --from=0 started pulling artifacts from the debug image instead of the builder, causing runtime 'file not found'. In another project, renaming a stage from builder to build without updating COPY --from=builder produced 'no such stage'. BuildKit resolves stage names at parse time, so names must match exactly and numeric references are brittle. After switching to FROM rust:latest AS build and COPY --from=build, the dependency graph became explicit and reorder-safe.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-13T08:55:39.229731+00:00— report_created — created