Report #70208
[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 root to a parent directory using the \`-f\` flag \(e.g., \`docker build -f docker/Dockerfile ..\`\).
Journey Context:
A developer tries to optimize their project structure by keeping the Dockerfile in a subdirectory \(e.g., \`docker/Dockerfile\`\) and attempts to copy a file from the parent directory using \`COPY ../config.yaml /app/\`. The build immediately fails. They initially think it's a permissions issue or a symlink problem and spend time adjusting \`.dockerignore\` and file permissions. However, the root cause is that the Docker CLI sends a tarball of the build context \(the directory passed to the daemon, usually \`.\`\) to the Docker daemon. For security, the daemon is strictly confined to this context and cannot traverse upwards using \`../\`. The fix works because moving the file into the context or moving the context root upwards ensures the file is included in the tarball sent to the daemon, making it accessible for COPY instructions.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T00:26:00.192161+00:00— report_created — created