Home › Docker

failed to solve: failed to read dockerfile: open Dockerfile: no such file or directory — how to fix

ERROR: failed to solve: failed to read dockerfile: open Dockerfile: no such file or directory
ERROR: failed to solve: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount123/Dockerfile: no such file or directory
unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /home/me/app/Dockerfile: no such file or directory

Quick fix: Run the build from the folder containing the Dockerfile: docker build -t myapp .. If it lives elsewhere or has another name, pass it explicitly: docker build -f path/to/Dockerfile.dev -t myapp .. Check the name with ls -la (no .txt extension, capital D).

What it means

docker build <context> defaults to reading <context>/Dockerfile. BuildKit reports the missing file as failed to read dockerfile: open Dockerfile; the legacy builder says unable to evaluate symlinks in Dockerfile path. Either way, nothing is wrong with Docker — the file just isn't where Docker looked.

Check:

pwd
ls -la            # is there a file named exactly "Dockerfile"?

Cause 1: running the build from the wrong directory

The . in docker build . is the current directory. If your Dockerfile is in ./backend:

cd backend && docker build -t myapp .
# or from the repo root:
docker build -t myapp ./backend

When the Dockerfile is in a subfolder but needs files from the root, keep the root as context and point at the file:

docker build -f backend/Dockerfile -t myapp .

-f paths are relative to your current directory, not to the context.

Cause 2: wrong file name

Docker is case-sensitive on Linux and expects Dockerfile with no extension. Common mistakes:

mv Dockerfile.txt Dockerfile
git mv dockerfile Dockerfile     # if tracked in git

Cause 3: Docker Compose points at the wrong place

In Compose, dockerfile: is relative to context::

services:
  api:
    build:
      context: ./api
      dockerfile: Dockerfile.dev    # means ./api/Dockerfile.dev

A common bug is writing dockerfile: ./api/Dockerfile and context: ./api, which resolves to ./api/api/Dockerfile.

Cause 4: CI runs in a different directory

In CI, the job may run before checkout, or in a different working directory. Print it:

- run: pwd && ls -la
- run: docker build -t myapp .

In GitHub Actions, actions/checkout must run before the build step, and working-directory: changes where . points.

Reading the Dockerfile from stdin

You can bypass the file entirely:

docker build -t myapp -f- . < Dockerfile

That's handy in scripts, but if COPY then fails with not found, the problem is the context, not the Dockerfile.

Last updated 2026-11-19.