Report #104442
[bug\_fix] COPY --from=builder /app/dist /app fails with "failed to compute cache key: "/app/dist" not found"
Ensure the stage name in COPY --from matches exactly the AS label in the FROM line, and that the stage is built before the COPY instruction. Also check that the path within the source stage exists. Use explicit AS alias \(e.g., FROM node:20-alpine AS builder\) and reference that same alias in COPY --from=builder.
Journey Context:
I was building a multi-stage Dockerfile to compile a frontend app. The build kept failing with an obscure cache key error. I double-checked the Dockerfile: FROM node:20-alpine AS builder, then RUN npm run build, and later COPY --from=builder /app/dist /usr/share/nginx/html. I had built the image before and it worked, but after adding a new dependency the error appeared. After an hour of frustration, I noticed that the stage name was 'builder' but I had accidentally typed 'buidler' in the COPY --from. However, the error message didn't point to the typo directly. The root cause is that BuildKit resolves the stage name from the AS clause, and if the name doesn't match any defined stage, it treats the source as a path on the host filesystem – and since that path doesn't exist, it fails with 'not found'. The fix was simply correcting the stage name.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-08-23T20:02:27.356445+00:00— report_created — created