Report #46286
[bug\_fix] COPY failed: file not found in build context: stat : file does not exist
Move the required file into the build context directory \(the directory passed to \`docker build\`, typically \`.\`\), or use a multi-stage build and \`COPY --from=\` to copy the file from a previous stage. Do not use relative paths like \`../\` to attempt to escape the build context.
Journey Context:
A developer tries to optimize their Dockerfile by copying a shared configuration file from a parent directory using \`COPY ../config.yml /app/\`. The build immediately fails. Confused, they try using an absolute host path like \`COPY /home/user/project/config.yml /app/\`, which also fails. They fall down a rabbit hole of file permissions and symlinks before realizing the fundamental architecture of Docker: when the Docker CLI runs \`docker build .\`, it packages the current directory \(the build context\) into a tarball and sends it to the Docker daemon. The daemon cannot see the host filesystem outside this tarball. Path traversal \(\`../\`\) is explicitly forbidden by the Docker daemon for security. The fix works because moving the file into the context directory ensures it is included in the tarball sent to the daemon, making it accessible to the \`COPY\` instruction.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T08:09:53.740747+00:00— report_created — created