failed to read dockerfile 🐳 Docker

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

  1. Run from the folder containing the Dockerfile
  2. Name it explicitly: docker build -f path/Dockerfile.dev .
  3. Check .dockerignore and compose build: settings

Detailed fix by platform

Docker

  1. docker build -f docker/Dockerfile.prod -t app .

Docker Compose

  1. bash
    services:
      app:
        build:
          context: .
          dockerfile: docker/Dockerfile.prod

How to diagnose

  1. Location — ls -la in the context folder
  2. Name — Exact filename and extension
  3. 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:

🧠 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.