Docker "the Dockerfile (Dockerfile) cannot be empty" in CI
Docker received a Dockerfile with no content. The file exists and is found, but it has zero usable instructions - usually because it is empty, gitignored, or was never written.
What this error means
A docker build fails right away with the Dockerfile (Dockerfile) cannot be empty. Unlike "failed to read dockerfile", the file is located - it just has nothing in it.
the Dockerfile (Dockerfile) cannot be empty
# or, when building from stdin with no input:
docker build - < /dev/null -> Dockerfile cannot be emptyCommon causes
The Dockerfile is genuinely empty
A zero-byte or whitespace-only file (a placeholder that was never filled in, or truncated by a bad write) has no instructions for Docker to build.
Building from stdin with no piped content
A docker build - reading the Dockerfile from standard input gets nothing when the upstream command produced no output, so Docker sees an empty file.
The file was gitignored or excluded from checkout
A .gitignore or sparse checkout can leave a placeholder/empty Dockerfile on the runner even though a real one exists on a developer machine.
How to fix it
Confirm the file has real content on the runner
Check the size and first lines from the job before building.
wc -c Dockerfile # 0 bytes means empty
head -5 Dockerfile # should start with a FROM (or # syntax=)Ensure stdin builds actually receive a Dockerfile
When piping, verify the producing command emits the Dockerfile content.
# pipe a real Dockerfile, not empty input
cat Dockerfile | docker build -t api -f - .How to prevent it
- Never commit empty placeholder Dockerfiles; add at least a
FROM. - Make sure the Dockerfile is tracked in git and not ignored or sparse-excluded.
- For stdin builds, assert the piped content is non-empty before building.