failed to solve: failed to read dockerfile: open Dockerfile: no such file or directory
docker build can’t find a Dockerfile in the build context you passed.
Seen on:
Docker
Meaning
By default Docker looks for a file named exactly Dockerfile at the root of the context (the path at the end of docker build, usually “.”). A different name (dockerfile.txt, Dockerfile.dev), wrong directory, or a .dockerignore entry excluding it all cause this.
Common causes
- Running docker build from the wrong folder
- File named differently (Dockerfile.dev, dockerfile.txt on Windows)
- .dockerignore excludes the Dockerfile
- Compose build: context/dockerfile paths wrong
⚡ Quick fix
- Run from the folder containing the Dockerfile
- Name it explicitly: docker build -f path/Dockerfile.dev .
- Check .dockerignore and compose build: settings
Detailed fix by platform
Docker
docker build -f docker/Dockerfile.prod -t app .
Docker Compose
- bash
services: app: build: context: . dockerfile: docker/Dockerfile.prod
How to diagnose
- Location — ls -la in the context folder
- Name — Exact filename and extension
- Ignore — .dockerignore contents
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
Most viewed in Docker
Other ways to find it
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 7 Oct 2026