Report #16162
[bug\_fix] COPY failed: file not found in build context: stat : file does not exist
Move the Dockerfile to the root of the repository \(or the directory containing the required files\) and specify the build context as the repository root. Change the build command to \`docker build -f path/to/Dockerfile .\` and adjust the \`COPY\` paths in the Dockerfile to be relative to the root.
Journey Context:
A developer is working in a monorepo with a service located in \`services/api/\`. They run \`docker build .\` inside the service directory, but the Dockerfile needs a shared protobuf file from \`../../proto/\`. They try \`COPY ../../proto/ ./proto/\` but the build fails. They try absolute paths, which also fails. After hours of verifying the file exists on their local machine, they realize Docker is not copying from the host filesystem directly. The Docker CLI packages the 'build context' \(the current directory \`.\`\) into a tarball and sends it to the daemon. The daemon cannot traverse \`../\` outside this tarball. The fix works because setting the build context to the repo root \(\`docker build -f services/api/Dockerfile .\`\) includes the \`proto/\` directory in the tarball sent to the daemon, allowing \`COPY proto/ ./proto/\` to succeed.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T01:56:28.890375+00:00— report_created — created