The file you are trying to COPY does not exist in the build context or is excluded by .dockerignore. Check the file path relative to the Dockerfile and your .dockerignore rules.
This error occurs during docker build when the COPY instruction cannot find the specified source file. Docker builds operate within a "build context" - the directory and files sent to the Docker daemon. Files outside this context or excluded by .dockerignore are invisible to the build. The path in COPY is relative to the build context root, not the Dockerfile location. This distinction often causes confusion.
Check that the file exists where Docker expects it:
# List files in build context directory
ls -la path/to/file
# Build context is the path you pass to docker build
docker build -t myapp . # Context is current directory
docker build -t myapp ./src # Context is ./src directoryCOPY paths are relative to the context root, not the Dockerfile.
Review your .dockerignore file:
cat .dockerignoreCommon patterns that might exclude your file:
# These exclude too much
*
!Dockerfile
# More precise
node_modules
.git
*.logTest by temporarily removing .dockerignore or commenting out rules.
Ensure COPY paths are relative to build context:
# If your structure is:
# project/
# Dockerfile
# src/
# app.js
# package.json
# Correct:
COPY package.json .
COPY src/ ./src/
# Wrong (these look for /src at context root):
COPY ./src/app.js . # Correct relative path
COPY /src/app.js . # Wrong - absolute pathWhen Dockerfile is not in the context root:
# Dockerfile at: docker/Dockerfile
# Files at: src/
# Specify Dockerfile location separately
docker build -f docker/Dockerfile -t myapp .The context is still "." - COPY paths are relative to ".", not to the Dockerfile.
Linux filesystems are case-sensitive:
# These are different files on Linux:
COPY README.md .
COPY readme.md .
# Check exact filename
ls -la | grep -i readmeEnsure the COPY instruction matches the exact case of the file.
See what Docker actually sees:
# Create a tarball of what Docker would send
tar -cvf context.tar --exclude-from=.dockerignore .
# Or use dry-run to check context size
docker build --no-cache --progress=plain -t test . 2>&1 | head -20Large context size might indicate missing .dockerignore.
Multi-stage Build Context: In multi-stage builds, COPY --from=builder copies from another stage, not from build context. These have different paths:
COPY --from=builder /app/dist ./dist # From builder stage
COPY ./config ./config # From build contextSymlinks: Symbolic links pointing outside the build context cannot be followed. Either copy the actual files or use bind mounts at runtime.
Git Repositories: If building from a Git URL, only committed files are included: docker build https://github.com/user/repo.git
dockerfile parse error line 5: unknown instruction: RRUN
How to fix 'unknown instruction' Dockerfile parse error in Docker
Error response from daemon: manifest for nginx:nonexistent not found: manifest unknown: manifest unknown
How to fix 'manifest for image:tag not found' in Docker
Error response from daemon: invalid reference format: repository name must be lowercase
How to fix 'repository name must be lowercase' in Docker
Error response from daemon: No such image
How to fix 'No such image' in Docker
Error response from daemon: Container is not running
How to fix 'Container is not running' when using docker exec