Report #48841
[bug\_fix] COPY failed: forbidden path outside the build context: ../../shared/utils.py
Move the Dockerfile to the root of the project \(or the directory containing the required files\) and adjust the COPY paths, or update the docker build command to point to the correct root directory as the build context \(e.g., docker build -f service-a/Dockerfile . instead of docker build .\). You cannot COPY files from outside the build context directory.
Journey Context:
A developer is working in a monorepo with a structure like project/service-a/ and project/shared/. They place a Dockerfile inside project/service-a/ and run docker build . from that directory. The build fails when trying to copy a shared utility. They try using relative paths like ../shared/utils.py, and even absolute paths, but Docker relentlessly rejects them. After digging into the Docker architecture, they realize the docker build argument \(the . at the end\) defines the 'build context'—a tarball of files sent to the Docker daemon. The daemon cannot access anything outside that tarball. The fix is to change the context to the monorepo root \(docker build -f service-a/Dockerfile .\) so the daemon receives the entire project, allowing COPY shared/utils.py . to succeed.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T12:28:00.223645+00:00— report_created — created