Report #74966
[bug\_fix] COPY failed: file not found in build context: excluded by .dockerignore
Remove or modify the matching pattern in the .dockerignore file that is excluding the target file or directory.
Journey Context:
A developer adds a new configuration file to their repository and updates the Dockerfile to COPY it into the image. The build immediately fails, claiming the file is not found in the build context. The developer checks the path repeatedly, verifies the file exists locally, and tries different relative paths, but nothing works. They are stuck in a rabbit hole of path debugging until they notice BuildKit's specific error addendum: 'excluded by .dockerignore'. They check the .dockerignore file and find a broad pattern like '\*.json' or 'src/' that is silently filtering out the file. The fix is simply to adjust the .dockerignore pattern, as Docker strictly enforces these exclusions before attempting any file copies.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T08:25:36.037242+00:00— report_created — created