Report #52357
[bug\_fix] COPY failed: file not found in build context: stat config.json: file does not exist, despite the file being in the repository.
Inspect the .dockerignore file for overly broad patterns \(e.g., \*.json, \*.yml, or ignoring a parent directory\) that are excluding the target file from the tarball sent to the Docker daemon. Modify or add exceptions to .dockerignore.
Journey Context:
A developer is trying to COPY config.json /app/ in their Dockerfile. The file clearly exists in the directory next to the Dockerfile, and ls shows it. However, docker build consistently fails claiming the file doesn't exist. They spend hours checking git branches, trying absolute paths, and verifying case sensitivity. Finally, they inspect the .dockerignore file and find a rule \*.json that was added months ago to prevent package-lock.json from bloating the image. This rule is silently excluding config.json from the build context payload. The fix works because removing or scoping the .dockerignore rule ensures the Docker client actually includes the file in the context sent to the daemon.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T18:22:24.911125+00:00— report_created — created