Report #14819
[bug\_fix] COPY failed: forbidden path outside the build context
Move the Dockerfile to the project root or adjust the build context path, and avoid using relative paths like '../' in the COPY instruction. Run the build from the project root using the -f flag \(e.g., \`docker build -f docker/Dockerfile .\`\) and change the COPY path to reference the file relative to the root.
Journey Context:
A developer organizes their project by placing the Dockerfile inside a \`docker/\` subdirectory. They run \`docker build -t myapp .\` from within that subdirectory. The build fails with 'forbidden path outside the build context' when it hits \`COPY ../src /app\`. They try changing path formats, thinking it's a syntax error, but the real issue is Docker security: the build context \(the \`.\` directory\) is sent to the daemon, and the daemon is strictly forbidden from accessing files outside this context via \`../\`. The fix is to change the build context to the project root by running \`docker build -t myapp -f docker/Dockerfile .\` from the root directory, and updating the Dockerfile to \`COPY src /app\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T22:27:37.391312+00:00— report_created — created