Report #97153
[bug\_fix] ERROR: failed to solve: failed to compute cache key: COPY --from=builder: no such stage
Name every stage explicitly with AS and reference the exact name in COPY --from, e.g. FROM node:20 AS builder and COPY --from=builder /app/dist /app/dist. Avoid relying on numeric stage indexes because they shift when stages are added or reordered.
Journey Context:
A team refactors a single-stage image to multi-stage. They add a final FROM nginx:alpine and write COPY --from=builder /app/build /usr/share/nginx/html, but the first stage was named FROM node:20 AS build, not builder. BuildKit reports no such stage. After checking the Dockerfile they align the names. They also remove a leftover COPY --from=0 that broke when a new stage was inserted earlier. The fix is to treat stage names as stable APIs in a multi-stage file.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-25T04:38:29.488969+00:00— report_created — created