Docker "failed to compute cache key: ... not found COPY --from" in CI
A COPY --from=<stage|image> is only valid if the source path exists in that stage or image. When the earlier stage never produced the file, or the path differs, BuildKit cannot hash a source that is not there and fails computing the cache key.
What this error means
A build fails at a COPY --from=... with failed to compute cache key: "<path>" not found. The referenced path is absent in the source stage or image.
ERROR: failed to solve: failed to compute cache key: "/app/dist": not found
# from: COPY --from=build /app/dist /app/distCommon causes
The source path was never created in the prior stage
If the build stage did not produce /app/dist, copying it later cannot hash a nonexistent path.
A wrong path or stage in --from
A typo in the path, or copying from the wrong stage/image, points at something that is not there.
How to fix it
Confirm the source path exists in the stage
- Add a debug
RUN lsin the source stage to verify the artifact. - Then copy the exact path it produced.
FROM node AS build
RUN npm run build
RUN ls -la /app/dist # confirm it exists
FROM nginx
COPY --from=build /app/dist /usr/share/nginx/htmlFix the --from target and path
- Reference the correct stage name or image and the real path.
COPY --from=builder /workspace/out /app/outHow to prevent it
- Verify the artifact path exists in the source stage before COPY.
- Name build stages clearly and reference them exactly.
- Avoid relative-vs-absolute path drift between stages.