Report #5475
[bug\_fix] COPY failed: forbidden path outside the build context
Move the required file into the build context directory, or adjust the docker build context path \(e.g., run 'docker build' from the parent directory and specify the Dockerfile path using -f\). Do not attempt to use relative paths like '../' in the COPY instruction.
Journey Context:
A developer attempts to share a configuration file across multiple services in a monorepo using 'COPY ../shared/config.yaml /app/' in their Dockerfile. The build immediately fails. They try using symlinks, which Docker also ignores because it resolves them outside the context. The root cause is that the Docker CLI packs the build context \(the directory specified at the end of the docker build command, usually '.'\) into a tarball and sends it to the daemon. For security and predictability, the daemon strictly confines extraction and COPY operations to within that tarball. Any path traversing up via '../' is rejected. The fix works by expanding the context boundary \(building from the repo root with '-f path/to/Dockerfile'\) so that '../shared' is now inside the context, or by moving the file into the current directory before building.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T21:21:00.210438+00:00— report_created — created