Skip to content
Latchkey

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.

docker
ERROR: failed to solve: failed to compute cache key: "/app/dist": not found
# from: COPY --from=build /app/dist /app/dist

Common 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

  1. Add a debug RUN ls in the source stage to verify the artifact.
  2. Then copy the exact path it produced.
Dockerfile
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/html

Fix the --from target and path

  1. Reference the correct stage name or image and the real path.
Dockerfile
COPY --from=builder /workspace/out /app/out

How 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.

Frequently asked questions

What causes ""cache key COPY --from not found""?
If the build stage did not produce /app/dist, copying it later cannot hash a nonexistent path.
How do I fix "cache key COPY --from not found"?
Confirm the source path exists in the stage

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card