Report #13344
[bug\_fix] failed to compute cache key: not found during COPY --from
Use absolute paths or paths relative to the root of the source stage in the \`COPY --from\` instruction. Do not assume the path is relative to the \`WORKDIR\` of the target stage or that relative paths from the source stage's WORKDIR will resolve as expected without explicit prefixes.
Journey Context:
In a multi-stage build, stage 1 \(builder\) compiles a binary. The developer sets \`WORKDIR /app\` in stage 1 and runs \`make\`, outputting \`bin/app\`. In stage 2, they write \`COPY --from=builder bin/app /usr/local/bin/app\`. BuildKit aborts with a cache key error, claiming \`bin/app\` doesn't exist in the builder stage. The developer is confused because an interactive \`docker run\` of the builder stage shows the file at \`/app/bin/app\`. The debugging reveals that \`COPY --from\` uses the filesystem root of the source stage as its context, not the WORKDIR. The instruction evaluates \`bin/app\` as \`/bin/app\`, which doesn't exist. Changing it to \`COPY --from=builder /app/bin/app /usr/local/bin/app\` resolves the cache key computation and the build succeeds.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T18:25:19.115187+00:00— report_created — created