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.
Related Resources
- Difference Between RUN and CMD in a Dockerfile — Dockerfile instructions
- How Do I Make a Comment in a Dockerfile? — write clearer Dockerfiles
- COPY with Docker Exclusion — optimize build context
- Introduction to Docker: Building Custom Images — Dockerfile guide
- Docker Quiz — test your Docker knowledge
We earn commissions when you shop through the links below.
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
SMTPfast
Developer-first email API
Send transactional and marketing email through a clean REST API. Detailed logs, webhooks, and embeddable signup forms in one dashboard.
QuizAPI
Developer-first quiz platform
Build, generate, and embed quizzes with a powerful REST API. AI-powered question generation and live multiplayer.
Want to support DevOps Daily and reach thousands of developers?
Become a SponsorFound an issue?
Related Posts
Also worth your time on this topic
Docker: Name is Already in Use by Container
Encountering the 'name is already in use by container' error in Docker? Learn why it happens and how to resolve it effectively.
Docker Security Hardening Checklist
Comprehensive security checklist for hardening Docker containers, images, and runtime environments.
60-90 minutes
Running Docker Containers on Your Linux Server
Install Docker and Docker Compose on Ubuntu, run your first container, deploy a WordPress stack with docker-compose, and set up Nginx as a reverse proxy in front of your containers.
60 minutes