docker: 'build' requires 1 argument. See 'docker build --help'
TLDR
The error docker: "build" requires 1 argument. See 'docker build --help' means you forgot to specify the build context (usually a directory) when running docker build. Always provide a path (like .) as the last argument.
Why Does This Error Happen?
When you run docker build, Docker expects a build context—a directory containing your Dockerfile and any files needed for the build. If you don't provide this argument, Docker doesn't know what to build.
Example of the error:
docker build
# Output:
# docker: "build" requires 1 argument. See 'docker build --help'.
How to Fix It
Add the build context (usually . for the current directory) at the end of your command:
docker build .
Or, if your Dockerfile is in a different directory:
docker build /path/to/context
You can also tag your image at the same time:
docker build -t my-image .
Common Pitfalls
- Forgetting the
.or path at the end of the command. - Using
docker build -t my-imagewithout the context (should bedocker build -t my-image .). - Running the command from the wrong directory (make sure your
Dockerfileis in the context directory).
Best Practices
- Always double-check your build context before running
docker build. - Use
docker build -t <name> .for most local builds. - For CI/CD, use absolute paths or ensure the working directory is correct.
Conclusion
The docker: "build" requires 1 argument error is a simple fix—just add the build context (like .) to your command. This ensures Docker knows where to find your Dockerfile and build resources.
These amazing companies help us create free, high-quality DevOps content for the community
DigitalOcean
Cloud infrastructure for developers
Simple, reliable cloud computing designed for developers
DevDojo
Developer community & tools
Join a community of developers sharing knowledge and tools
Want to support DevOps Daily and reach thousands of developers?
Become a SponsorFound an issue?