failed to solve with frontend dockerfile.v0: failed to read dockerfile
Fixes BuildKit 'failed to read dockerfile' errors where the Dockerfile cannot be found in the build context. Use when the build fails before any step runs, usually with 'error from sender: walk ...: no such file or directory'. Not for Dockerfile syntax errors, which fail later with parse errors.
TL;DR: The Dockerfile is not where the builder looks for it. Either the context path is wrong or the -f flag points outside it. Run docker build -f [Dockerfile path] [context dir] making sure the -f path is relative to the context, or just cd into the right directory and build from .. BuildKit reads the Dockerfile out of the build context, not off your disk directly.
The error
failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount123/Dockerfile: no such file or directoryFix it
- Confirm the Dockerfile exists where you think:
ls -la Dockerfile docker/Dockerfile 2>/dev/null Expected: you find the actual file.
- If the Dockerfile lives in a subdirectory, point -f at it RELATIVE to the context:
docker build -f docker/Dockerfile . Expected: build starts instead of failing at the read step.
- If the context itself is wrong, fix the PATH argument (the last one):
docker build -f docker/Dockerfile ./subdir-with-code Expected: both Dockerfile and sources resolve.
When this applies
- Build fails instantly with "failed to read dockerfile" before any RUN/COPY step
- Monorepos where the Dockerfile is not at the repo root
When this does NOT apply
- "Dockerfile parse error" (file was found, contents are bad)
- COPY failures (Dockerfile was read fine)
Versions
BuildKit-era Docker (20.10+, default builder in 23+). Classic builder says "unable to prepare context" variants.
Why it happens
With BuildKit, the client sends the build context to the builder and the frontend reads the Dockerfile from inside that context. If the context root does not contain the Dockerfile at the -f relative path, the read fails before anything else runs.
Edge cases
-fwith an absolute path only works if that path is inside the context; otherwise BuildKit rejects it..dockerignorecan exclude the Dockerfile itself, producing this exact error.- Filenames are case-sensitive on Linux:
dockerfileis notDockerfile.
Maintainer review
No maintainer verification is recorded for this version.
This records the version a maintainer checked. It does not assert that the version is the latest upstream release.