Report #25180
[bug\_fix] COPY failed: file not found in build context: stat : file does not exist
Ensure the file being copied exists within the build context root \(the directory passed to \`docker build\`, typically \`.\`\). If copying from a previous stage, use \`COPY --from=\`. You cannot copy files from outside the build context \(like \`../something.txt\`\).
Journey Context:
A developer is trying to copy a configuration file from a parent directory into their Docker image using \`COPY ../config.yml /app/\`. The build fails instantly. They verify the file exists on their host machine, leading to confusion. They fall down a rabbit hole checking file permissions and typos. Eventually, they discover that the Docker CLI sends the build context \(the current directory \`.\`\) to the daemon, and the daemon cannot access anything above that root directory for security and portability reasons. To fix it, they either move the Dockerfile to the project root and adjust the COPY path, or they change the build context itself \(e.g., running \`docker build -f dir/Dockerfile ..\` from a subdirectory\). This works because the daemon now receives the parent directory as the context root, making the file accessible.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T20:40:26.199055+00:00— report_created — created