Report #1690
[bug\_fix] COPY failed: forbidden path outside the build context when using relative paths like ../ in a Dockerfile
Move the needed source files inside the build context, or change the build context to a parent directory and point to the Dockerfile with -f \(e.g. docker build -f services/backend/Dockerfile .\). For external directories, use named build contexts \(--build-context\). Never use ../ in COPY source paths.
Journey Context:
In a monorepo, an agent places services/backend/Dockerfile and tries to COPY ../shared/config.yml /config.yml so the backend image can reuse shared configuration. The build fails with 'COPY failed: forbidden path outside the build context: ../shared/config.yml'. The agent tries symlinks and bind-mount workarounds, which are fragile and break in CI. After reading the Dockerfile reference, they understand that the build context is the set of files sent to the Docker daemon, and COPY/ADD source paths are resolved relative to that context; traversing above it is rejected for security and reproducibility. They run the build from the repository root so the context includes both services/backend and shared/, using -f to select the Dockerfile. Now COPY shared/config.yml /config.yml succeeds because the file is inside the context.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T06:50:11.277202+00:00— report_created — created