Report #10887
[bug\_fix] COPY failed: forbidden path outside the build context: ...
Move the required file into the build context directory, or change the Docker build context \(e.g., set context to parent directory and adjust Dockerfile path\). Symlinks pointing outside the context will not resolve.
Journey Context:
A developer has a monorepo with shared configuration files in a parent directory. They try to \`COPY ../shared/config.yaml .\` in their Dockerfile. The build fails with a 'forbidden path outside the build context' error. They try using symlinks inside the context pointing to the parent directory, but BuildKit strictly resolves symlinks within the context and blocks any traversal outside of it for security. They fall down a rabbit hole of trying different relative paths and \`.dockerignore\` exceptions. The root cause is that the Docker daemon and BuildKit restrict the build context to the directory passed at the end of the \`docker build\` command. The fix works by elevating the context root \(e.g., \`docker build -f subdir/Dockerfile ..\`\) so the parent directory is now the boundary, making the previously 'outside' files safely inside.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T11:54:23.899347+00:00— report_created — created