docker build says there is no build stage in the current context
Error response from daemon: No build stage in current contextShort answer
Every Docker image build needs at least one FROM line, because FROM starts a build stage. The error means the Dockerfile Docker read has none: it is empty, holds only comments or ARG lines, or it is not the file you meant. Print the file Docker actually reads, then fix the file or the -f path.
Fix it fast
1Find out which cause you have
Print the Dockerfile Docker will use, with line numbers. If you pass -f, print that file; otherwise it is the file named Dockerfile at the root of the build context.
cat -n Dockerfile2Match what you see, then jump to its fix
What does the error look like?
Error response from daemon: No build stage in current context
Cause 1 of 2
The Dockerfile has no FROM instruction
1Check
A Dockerfile must begin with FROM. Only parser directives, comments and global ARG lines may come before it. An empty file, one saved by mistake, or one where FROM got deleted has no stage at all.
wc -c Dockerfile
grep -n "^FROM" Dockerfile2Fix
Add a FROM line naming your base image, then the rest of your instructions after it.
FROM node:24
WORKDIR /app
COPY . .
RUN npm ci3Verify
The build starts and runs the first step.
docker build -t my-app .Confirmed by docs.docker.com
Cause 2 of 2
Docker reads a different file than the one you edited
1Check
Without -f, Docker uses the file named Dockerfile at the root of the build context, which is the PATH argument. In a monorepo or CI job, the context or the -f path can point at another folder, or at an empty file.
pwd
ls -l Dockerfile docker/Dockerfile 2>/dev/null2Fix
Name the Dockerfile and the context explicitly.
docker build -f docker/Dockerfile -t my-app .3Verify
The build output starts with the stage from the file you named.
docker build -f docker/Dockerfile -t my-app .Confirmed by docs.docker.com
How do I stop it coming back?
- Keep one Dockerfile per image in a predictable path and always pass -f and the context in CI.
- Run docker build in CI on every change so an emptied Dockerfile cannot reach a release.
- Name stages with FROM ... AS name so later COPY --from and --target refer to something that exists.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Servers
apk cannot find py-pip in an Alpine Docker image
py-pip (no such package):
On current Alpine releases there is no package called py-pip.
2 causes, each with a fixServers
ng serve runs in the container but localhost:4200 does not open
The browser cannot open localhost:4200 although ng serve is running in the container
ng serve listens on localhost by default, which inside a container is the container itself.
3 causes, each with a fixServers
Angular routes return 404 from nginx when you refresh or open a link
The home page loads, but refreshing /some/route shows an nginx 404
Angular routes like /users/42 are not files, so nginx looks for them on disk and returns 404.
3 causes, each with a fixServers
AH00558: Apache in Docker cannot reliably determine its fully qualified domain name
Set the 'ServerName' directive globally to suppress this message
AH00558 is a warning, not a crash.
2 causes, each with a fixServers
Apache in a Docker container logs AH01114 when it proxies to a backend
AH01114: HTTP: failed to make connection to backend: api
Apache's proxy worker could not open a connection to the address in ProxyPass.
5 causes, each with a fixServers
Apache logs SIGWINCH and exits on its own
the httpd container stops although nothing crashed
SIGWINCH is Apache's graceful-stop signal.
2 causes, each with a fix