Report #77916
[bug\_fix] COPY failed: file not found in build context: stat \[filename\]: file does not exist, despite the file being present in the repository.
Check the .dockerignore file for rules that are inadvertently excluding the file or its parent directory. Modify the .dockerignore to allow the necessary files to be included in the build context.
Journey Context:
A developer adds a new configuration file, 'config/prod.yaml', to their repo and adds 'COPY config/prod.yaml /app/config/' to their Dockerfile. The build immediately fails, claiming the file doesn't exist. The developer verifies the file is on their disk, checks git status, and even hardcodes the absolute path, which fails due to context boundaries. They suspect a Docker daemon caching bug and restart Docker. Still failing. The actual culprit is a wildcard rule deep in their .dockerignore file, such as '\*.yaml' or ignoring the 'config' directory entirely. Because .dockerignore filters the build context before it is sent to the BuildKit daemon, the daemon literally never sees the file. Reviewing the .dockerignore file and adding an exception like '\!config/prod.yaml' or removing the broad exclusion resolves the phantom missing file.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T13:22:46.630077+00:00— report_created — created