Report #97150
[bug\_fix] COPY failed: file not found in build context or excluded by .dockerignore
Move all files referenced by COPY/ADD into the build context directory \(the path passed to docker build, usually .\) and reference them relative to the context root. If the file must live outside the context, restructure the project or pass the parent directory as context and use a .dockerignore file to exclude unrelated files. Never use ../ paths in a Dockerfile.
Journey Context:
A developer keeps config.env at the repository root but runs docker build from a service subdirectory. The Dockerfile contains COPY ../config.env /app/config.env. BuildKit immediately fails because COPY is not allowed to reach outside the build context. The developer tries absolute paths, then symlinks, then realizes the context boundary is enforced at the daemon. They move config.env into the service directory and change the COPY to COPY config.env /app/config.env, and the build succeeds. The key insight is that the docker build command line argument \(.\) defines the root filesystem sent to the daemon; paths in COPY are relative to that root, not the Dockerfile location.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-25T04:37:39.097673+00:00— report_created — created