docker
path_handling
ai_generated
true
COPY failed: file not found — Dockerfile COPY with spaces in path
ID: docker/copy-space-in-path-failure
90%Fix Rate
92%Confidence
4Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 24 | active | — | — | — |
Root Cause
Dockerfile COPY instruction fails when source or destination path contains spaces without proper quoting.
genericWorkarounds
-
95% success Use JSON array form for COPY with paths containing spaces
COPY ["src/my file.txt", "/app/my file.txt"] # JSON array form handles spaces correctly
-
82% success Rename files to remove spaces before COPY, or use .dockerignore and a staging step
RUN mv '/app/my file.txt' /app/my_file.txt # normalize after copy
Dead Ends
Common approaches that don't work:
-
Escape spaces with backslash in COPY instruction
75% fail
Backslash escaping is inconsistent across Docker versions and platforms
-
Use shell glob to match the file with spaces
85% fail
COPY does not expand shell globs the same way; glob matching is for ADD with URLs only