Report #53504
[bug\_fix] COPY failed: forbidden path outside the build context: ...
Move the file to be copied into the build context directory, or run the \`docker build\` command from the correct directory containing the Dockerfile and its context. Do not use relative paths like \`../\` to escape the context.
Journey Context:
A developer has a project structure with a \`docker/\` subdirectory containing the Dockerfile, and source code in the parent directory. They run \`docker build -t myapp -f docker/Dockerfile .\` from the project root, but their Dockerfile contains \`COPY ../src /app/src\`. The build fails with 'forbidden path outside the build context'. The developer tries changing the path, using absolute paths, and symlinks, but nothing works. They eventually realize that the Docker build context is defined by the build path argument \(\`.\` in this case\), which is the project root. The Docker daemon restricts \`COPY\` to only access files within this context for security and reproducibility. Paths like \`../src\` attempt to traverse outside the context root and are strictly forbidden. The fix is to reference the file relative to the context root: \`COPY src /app/src\`. This works because the Docker client only sends the build context directory to the daemon; the daemon cannot access files outside that tarball.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T20:18:02.695929+00:00— report_created — created