Common causes
- The file path in COPY is wrong — check relative to the build context, not the Dockerfile location
- The file is listed in .dockerignore and is being excluded from the build context
- You're running docker build from the wrong directory so the file isn't in the context
- The file genuinely doesn't exist and needs to be created before building
How to fix it
- Verify the file exists and the path is correct relative to where you run docker build
- Check your .dockerignore — if it excludes the file, remove that exclusion or adjust the pattern
- Run docker build from the project root: docker build -t myapp . (where . includes the needed files)
- Use a specific build context: docker build -t myapp -f path/to/Dockerfile path/to/context
Example
$ docker build -t myapp .
COPY failed: file not found in build context or excluded by .dockerignore: stat config/settings.json: file does not existCOPY instruction references config/settings.json but the file doesn't exist in the build context
Browse more errors
The Developer Hub covers 150+ errors across Git, npm, Node.js, Python, TypeScript, and Docker — with plain-English explanations and fix steps.
