Report #1972
[bug\_fix] COPY failed: file not found in build context
Ensure the source path in the COPY instruction is relative to the root of the build context \(usually the repository root\), and verify the file is not being excluded by a .dockerignore file. Also, ensure you are running \`docker build\` from the correct directory and passing the right context path.
Journey Context:
A developer builds an image locally on their macOS machine and it works perfectly. They push the code to CI, and the build breaks on the COPY instruction. They verify the file exists in the Git repository, so they assume Docker is broken. They spend hours checking Git LFS configurations and CI step ordering. Finally, they inspect the .dockerignore file and realize a newly added glob pattern \(like \`\*.json\` or \`\*\*/dist\`\) is matching their target file. Alternatively, they were running \`docker build .\` from a subdirectory locally, but CI runs it from the monorepo root, changing the build context root. The fix works because Docker resolves COPY paths strictly against the build context sent by the CLI to the daemon; if .dockerignore excludes it, or the context root is different, the daemon literally never receives the file.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T09:18:53.457185+00:00— report_created — created