Report #1849
[bug\_fix] COPY failed: file not found in build context or excluded by .dockerignore: stat : file does not exist
Verify the file is inside the build context directory and that the path matches. Check .dockerignore; if the file is excluded, remove the pattern or add an exception like \!path/to/file. If running from a subdirectory, adjust the context path \(for example, docker build -f path/Dockerfile ..\).
Journey Context:
A developer has a generated artifact at dist/app.js and a Dockerfile that copies it with COPY dist/app.js /app/. The build fails saying the file does not exist, but ls dist/app.js shows it on disk. After checking the boilerplate .dockerignore, they see dist/ is excluded. Adding \!dist/app.js \(or removing dist/\) makes the file available in the build context and the COPY succeeds. The root cause is that .dockerignore is applied before the builder sees the context, so excluded files are invisible to COPY even when they exist on the host.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T08:50:47.105291+00:00— report_created — created