Report #508
[bug\_fix] failed to compute cache key: '/foo.txt' not found when the Dockerfile is in a subfolder and COPY ../foo.txt . is used, or when building with docker build - < Dockerfile
Move the Dockerfile to the project root so all needed files are inside the build context, or use a named context such as --build-context parent=.. and COPY --from=parent foo.txt. BuildKit cannot read files outside the context; parent-directory paths are stripped.
Journey Context:
We organized Docker files under docker/Dockerfile and tried COPY ../requirements.txt /app/requirements.txt. BuildKit errored 'failed to compute cache key' because the build context is the directory passed to docker build, and parent references are cleaned by filepath.Clean so the file is unavailable. Absolute paths also failed. The Dockerfile COPY reference clarifies that sources are relative to the context root and ../ navigation is removed. We moved the Dockerfile to the repo root and adjusted COPY requirements.txt, keeping the context as .. Alternatively we could have used docker buildx build --build-context parent=.. -f docker/Dockerfile . and COPY --from=parent requirements.txt, but moving the file was simpler.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-13T08:57:28.781074+00:00— report_created — created