Report #54224
[bug\_fix] COPY failed: forbidden path outside the build context
Move the required files into the build context directory, or change the build context root \(e.g., change the Docker build path from the subdirectory to the repository root\). You cannot use COPY ../somefile.txt . to traverse above the context.
Journey Context:
A developer has a monorepo with a shared library in the parent directory. In their Dockerfile located in services/api/, they write COPY ../shared-lib /app/shared-lib. The build immediately fails. They try using absolute paths, symlinks, or changing the Docker context in Docker Compose, but BuildKit strictly enforces security by forbidding paths outside the defined build context. The rabbit hole involves trying to hack around it with .dockerignore exceptions or changing daemon settings. The fix works because Docker's build context is the boundary of files sent to the daemon; moving the Dockerfile to the repo root and adjusting the COPY paths ensures all files are within the tarball sent to the daemon.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T21:30:46.733574+00:00— report_created — created