Docker is a technology that allows you to run applications on top of Linux containers. It enables developers to build, test, and ship code in a more scalable and efficient way. With Docker, organizations can you can do rapid software deployment without changing the current workflow too much. The environment itself is highly portable and was designed with efficiencies that allow you to run multiple Docker containers in a single environment at the same time.
Dockerfile is a text-based configuration file which contains commands that will be used later on to build an image. Using docker build
command, users can create an automated build that executes several command-line instructions in succession.
docker: “build” requires 1 argument is an extremely common error messages beginners may face while building an image using the Dockerfile. This article is a compilation of available information about this specific error message as well as how to fix it.
Reproduce “Docker build Requires 1 Argument” error
Let’s take a look at a simple Dockerfile example which contains the following content:
FROM centos:7
RUN yum -y install wget \
&& yum -y install unzip \
&& yum install -y nc \
&& yum -y install httpd && \
&& yum clean all
EXPOSE 6379
ENTRYPOINT ["ping"]
CMD ["google.com"]
Code language: CSS (css)
What we want to achieve here is fetching CentOS 7 image as the base image, then install unzip
and httpd
and tries to send ping
signal to Google. Obviously, it does not serve any other purpose rather than being a Dockerfile example which also includes a few utility commands.
If we try to build the image using docker build
, we should see docker: “build” requires 1 argument error. Below is the full output of the error message:
$ docker build
"docker build" requires exactly 1 argument.
See 'docker build --help'.
Usage: docker build [OPTIONS] PATH | URL | -
Build an image from a Dockerfile
Code language: JavaScript (javascript)
Even if we run docker build
with different options, the issue may arise. For example:
$ docker build -t test_image/centos
"docker build" requires exactly 1 argument.
See 'docker build --help'.
Usage: docker build [OPTIONS] PATH | URL | -
Build an image from a Dockerfile
Code language: JavaScript (javascript)
Incorrect docker build arguments
In order to avoid gettting docker: “build” requires 1 argument in the future, we need to get a good grasp at how docker build
command works.
The docker build command builds an image from a Dockerfile
and a context. The context is a of files at a specified location, either a path or an URL. docker build
requires exactly one argument.
Docker only accepts a directory on your local filesystem as PATH
and a valid Git repo as URL
. Failed to provide either argument may lead to docker: “build” requires 1 argument or other error messages.
Suppose you’re already in the directory where you’ve placed the Dockerfile. In order to fix docker: “build” requires 1 argument add a dot to the command so it becomes docker build .
instead of docker build
. That way, the build command that uses the current directory (.
) as build context.
$ docker build .
Sending build context to Docker daemon 3.054kB
Step 1/4 : FROM centos:7
14.04: Pulling from library/centos
2e6e20c8e2e6: Extracting [=======> ] 26.86MB/70.69MB
0641a797d01d: Download complete
516223a864ea: Download complete
Code language: JavaScript (javascript)
Alternatively, you can use -f flag followed by a path pointing to the another Dockerfile to build an image.
$ docker build -f /home/user/example/Dockerfile .
The Dockerfile doesn’t have to be named Dockerfile, though. For example, we can use a file named no_Dockerfile
.
$ docker build -f /home/user/example/no_Dockerfile .
Don’t forget the dot, especially in build commands with arguments:
$ docker build -t test_image/centos --build-arg JAVA_ENV=1.6 .
We hope that the information above helped you learn a bit more about docker: “build” requires 1 argument error. You may want to check out our tutorials for Docker such as How to fix “docker-compose: command not found, Fix “LookupError: unknown encoding: cp65001” error in Docker and How to install docker and docker-compose on Raspberry Pi.
If you spot an error in the article, please kindly correct us using the comment section below.