Report #81731
[bug\_fix] ERROR: failed to solve: failed to compute cache key: failed to copy files: forbidden path outside the build context: ...
Move the required file into the build context directory, or restructure the Dockerfile. Run \`docker build\` from the root of the project and adjust the Dockerfile paths accordingly.
Journey Context:
A developer has a monorepo with a shared configuration file one directory up from their Dockerfile. They attempt \`COPY ../shared\_config.yaml /app/\`. The build fails with 'forbidden path outside the build context'. They try using an absolute path, which also fails. The rabbit hole involves trying to symlink the file or change the Docker daemon data root. The root cause is that BuildKit, unlike some legacy Docker builder quirks, strictly sandboxes the build to the provided context directory \(the \`.\` in \`docker build .\`\) for security and reproducibility. It cannot reach up the directory tree. The fix is to run \`docker build\` from the root of the monorepo, adjust the Dockerfile paths \(e.g., \`COPY shared\_config.yaml /app/\`\), and update the \`.dockerignore\` if necessary.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T19:47:04.711255+00:00— report_created — created