Skip to content
Latchkey

Docker COPY --from path not found in a multi-stage build in CI

The named stage is valid, but the path you copy from it does not exist. BuildKit reports "failed to compute cache key: ... not found" because the artifact was never built, or it lives at a different path than the COPY expects.

What this error means

A COPY --from=builder /app/dist /out step fails with "failed to compute cache key: ... not found" (classic builder prints "COPY failed: stat ...: no such file or directory"). The stage name itself resolves fine.

docker build
ERROR: failed to solve: failed to compute cache key: failed to calculate checksum
of ref ...: "/app/dist": not found

Common causes

The artifact was never produced in that stage

The build step in the named stage did not create the expected output, so the path the COPY references is absent.

The path differs from the COPY source

A different WORKDIR or output filename in the builder stage means the file exists, but not at the path you copy from.

How to fix it

Verify the path inside the source stage

  1. Add a temporary RUN ls -la <dir> in the builder stage to print what it produced.
  2. Match the COPY source to the real output path and filename.
  3. Confirm the build step that creates the artifact actually ran.

Align WORKDIR and output paths

Use an absolute, explicit output path in the builder and copy from exactly that path.

Dockerfile
FROM node:20 AS builder
WORKDIR /app
RUN npm run build   # outputs to /app/dist

FROM nginx
COPY --from=builder /app/dist /usr/share/nginx/html

How to prevent it

  • Use absolute output paths in builder stages.
  • Confirm the artifact is produced before copying it.
  • Keep COPY --from sources aligned with the builder WORKDIR.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →