Report #13529
[bug\_fix] COPY failed: file not found in build context: stat \[file\]: file does not exist
Check the '.dockerignore' file and remove any patterns that are inadvertently excluding the required files from the build context.
Journey Context:
A developer adds 'COPY .env /app/.env' to their Dockerfile. The build fails, claiming the file does not exist in the build context. The developer verifies the file exists locally, checks for typos, and tries absolute paths, but nothing works. After an hour of frustration, they stumble upon the '.dockerignore' file. It contains a blanket '\*.env' rule to prevent secrets from leaking into images. The Docker daemon excludes '.env' files before the build even starts, so the COPY command fails. Removing or modifying the '.dockerignore' pattern fixes the issue. This highlights that the build context is filtered before being sent to the daemon.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T18:54:45.232615+00:00— report_created — created