Fixing the Error: docker: “build” requires 1 argument. See ‘docker build –help’

When working with Docker, you may encounter the following error:

docker: "build" requires 1 argument.
See 'docker build --help'.

This happens when the docker build command is missing a required argument. Let’s understand why it occurs and how to fix it.


1️⃣ Why This Error Happens

The docker build command requires a build context argument. The build context is the directory where Docker looks for the Dockerfile and other files to copy into the image.

If you just run:

docker build

Docker doesn’t know where to look, so it fails.


2️⃣ Correct Usage of docker build

✅ Building from the Current Directory

If your Dockerfile is in the current directory:

docker build -t myapp:latest .
  • -t myapp:latest → names the image
  • . → sets the build context to the current directory

✅ Building from a Custom Directory

If your Dockerfile is in ./app:

docker build -t myapp:latest ./app

✅ Building with a Custom Dockerfile Name

If your Dockerfile is named Dockerfile.dev:

docker build -f Dockerfile.dev -t myapp:dev .

✅ Building from a Remote Git Repository

You can even build directly from GitHub:

docker build -t myapp:git https://github.com/user/repo.git

3️⃣ Common Mistakes That Trigger the Error

MistakeExampleFix
Forgetting the contextdocker build -t myappAdd . at the end
Wrong pathdocker build -t myapp ./wrongpathEnsure the path exists
Missing Dockerfiledocker build . (but no Dockerfile present)Use -f to specify file

📌 Summary

The error:

docker: "build" requires 1 argument.

means Docker needs a build context (directory or URL).

✅ Always provide a path, typically . for the current directory:

docker build -t myapp:latest .
Sharing Is Caring:

Leave a Comment