ProjectStack
docker

failed to solve: failed to compute cache key: "/X": not found

BuildKit (Docker's modern build engine) couldn't find the file or directory referenced in a COPY or ADD instruction when computing the build cache. This is the BuildKit equivalent of the classic 'COPY failed' error and means the file path in your Dockerfile doesn't exist in the build context.

Common causes

  • The path in COPY or ADD doesn't exist in the build context directory
  • A multi-stage build references a file from a previous stage that wasn't copied or created
  • The build context (the . in docker build .) doesn't include the file — check the working directory
  • A typo in the file or directory name in the Dockerfile COPY instruction

How to fix it

  1. Check the file path in your COPY instruction against the actual file structure in your project
  2. Run ls in the build context directory to confirm the file exists: ls -la src/
  3. For multi-stage builds, make sure the previous stage creates or copies the file: COPY --from=builder /app/dist ./dist
  4. Review .dockerignore to ensure the needed files aren't excluded

Example

$ docker build . #5 [2/3] COPY dist/ /app/ #5 ERROR: failed to solve: failed to compute cache key: "/dist": not found

BuildKit can't find the dist/ directory — it wasn't created yet or doesn't exist in the build context

Browse more errors

The Developer Hub covers 150+ errors across Git, npm, Node.js, Python, TypeScript, and Docker — with plain-English explanations and fix steps.