Report #3313
[bug\_fix] failed to solve: failed to compute cache key: failed to calculate checksum of ref ...: "/foo": not found when COPY references a file outside the build context
Move the needed files into the build-context directory \(the path passed to docker build\) or change the build context so the source path is inside it. In a monorepo, run docker build from the repo root with the correct context, e.g. \`docker build -f service/Dockerfile .\`, or use BuildKit named contexts \(\`--build-context\`\) to bring in external paths explicitly.
Journey Context:
A developer puts the Dockerfile in \`service/Dockerfile\` and runs \`docker build -t app service/\`. The Dockerfile contains \`COPY ../config.yml /app/config.yml\`. The build fails with a cache-key error because \`..\` is outside the context that was sent to BuildKit, so the file is not visible. They check \`ls ../config.yml\` and the file exists, so they think Docker is broken. After reading the error closely they see the path is being stripped to \`/foo\` and realize Docker only allows COPY/ADD sources inside the build context. They move the build command up to the repo root and pass the context as \`.\` \(or move config.yml into \`service/\`\). The build now succeeds because the source is inside the context tarball BuildKit evaluates.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T16:30:32.552543+00:00— report_created — created