Report #76894
[bug\_fix] COPY failed: file not found in build context: stat : file does not exist
Move the required file into the build context directory, or move the Dockerfile to the root of the project and adjust the COPY path to be relative to the context root. Docker cannot copy files from outside the designated build context.
Journey Context:
A developer tries to optimize their project structure by placing the Dockerfile in a 'docker/' subdirectory. They run \`docker build -t myapp -f docker/Dockerfile .\` from the project root, but the Dockerfile contains \`COPY ../config.yaml /app/\`. The build fails. They try using absolute paths, which also fails. After digging into Docker architecture, they realize the Docker CLI sends the context directory \(the \`.\` argument\) as a tarball to the daemon. The daemon only sees inside that tarball; it cannot resolve \`../\` to escape it, nor can it access the host's absolute paths. The fix is to keep the Dockerfile in the subdirectory but change the COPY instruction to \`COPY config.yaml /app/\` since the build context is the project root.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T11:39:54.762135+00:00— report_created — created