Report #594
[bug\_fix] ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref ...: "/app/config.yaml": not found
The COPY source path is relative to the build context root, not the Dockerfile directory. Run \`docker build\` from the directory that contains the file, or adjust the COPY path to match the context layout. Check \`.dockerignore\` to ensure the file is not excluded. If the Dockerfile is in a subdirectory, either move it to the context root or pass the context root with \`-f path/to/Dockerfile\`.
Journey Context:
I was building a Go service in a monorepo. The Dockerfile lived at \`services/api/Dockerfile\` and I ran \`docker build -f services/api/Dockerfile services/api/\`. Inside the Dockerfile I had \`COPY go.mod .\`, but the build failed with a cache-key checksum error saying \`/go.mod\` was not found. I checked the directory — \`services/api/go.mod\` definitely existed. I then realized that BuildKit computes a cache key from the file's checksum \*within the build context\*, and my context was only \`services/api/\`, so the path \`go.mod\` was correct but the file was actually at the context root. The real problem was that I had previously run the build from the repo root with \`COPY services/api/go.mod .\`, and now the cached layer was looking for a file that no longer existed in the new context. I cleared the build cache with \`docker builder prune\`, moved \`COPY go.mod .\` and \`COPY go.sum .\` to the top, and made sure the context directory I passed always contained those files. After that the cache key computed correctly because the context root was the directory holding the files.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-13T09:57:25.143415+00:00— report_created — created