docker
build
ai_generated
true
COPY failed: file not found in build context
ID: docker/copy-failed-stat
96%Fix Rate
97%Confidence
50Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 24 | active | — | — | — |
| 27 | active | — | — | — |
Root Cause
COPY instruction references a file that doesn't exist in the Docker build context.
genericWorkarounds
-
93% success Check .dockerignore — the file may exist but be ignored during context transfer
Remove the file pattern from .dockerignore
Sources: https://docs.docker.com/build/building/context/#dockerignore-files
-
95% success Verify the file path is relative to the build context (the directory passed to docker build)
docker build -f Dockerfile . — the '.' is the build context root
Dead Ends
Common approaches that don't work:
-
Using absolute host paths in COPY
90% fail
Docker COPY only works within the build context; absolute paths are forbidden
-
Using volume mounts during build
85% fail
docker build doesn't support volumes; only RUN, COPY, ADD work
Error Chain
Frequently confused with: