docker tutorials

Error “docker build” requires exactly 1 argument. See ‘docker build –help’

This sneppet shows you how to resolve error “docker build” requires exactly 1 argument. See ‘docker build –help’  that you face while building docker image.

Let’s say you have some source code and Dockerfile in your project directory “myProj” and you are trying to build docker image for the first time and resulted with following error.

~/myProj$ docker build -t sneppets/sshd-example
"docker build" requires exactly 1 argument.
See 'docker build --help'.

Usage:  docker build [OPTIONS] PATH | URL | -

Build an image from a Dockerfile


To build an image from Dockerfile you need to use the following docker command.

docker build [OPTIONS] PATH | URL | -

Here we chose to build image with PATH option. Let’s see how to do that.

Build with PATH

To build with PATH you need specify dot “.”, so that all the files in the local project directory myProj get tar’d and sent to the Docker daemon. The PATH used here will find the files for the “context” of the build on the Docker daemon.

Therefore if you are already in to the project directory as shown here “myProj” then you just need to use dot “.” as shown.

$ docker build .

Tag an image with -t

If you want to build a docker image with PATH, repository name (sneppets/sshd-example) and tag (by default latest) then you need to use the following command in case you are in the project directory already. If you don’t mention tag it will take latest by default.

$ docker build -t sneppets/sshd-example .

Note, If you are not in the project directory then you can mention full path instead of dot “.” In our case we are using dot as shown below and could successfully build docker image.

~/myProj$ docker build -t sneppets/sshd-example .
Sending build context to Docker daemon  2.048kB
Step 1/4 : FROM ubuntu
 ---> 4e5021d210f6
Step 2/4 : MAINTAINER sneppets <[email protected]>
 ---> Running in 4ea3abe2dcf5
Removing intermediate container 4ea3abe2dcf5
 ---> f8248d45bbbb
Step 3/4 : RUN apt-get update && apt-get install -y openssh-server
 ---> Running in a26154250cb2
Get:1 bionic-security InRelease [88.7 kB]
Get:2 bionic InRelease [242 kB]
Get:3 bionic-security/restricted amd64 Packages [37.0 kB]
Get:4 bionic-security/main amd64 Packages [870 kB]
Get:5 bionic-security/multiverse amd64 Packages [7904 B]
Get:6 bionic-security/universe amd64 Packages [835 kB]
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
Removing intermediate container a26154250cb2
 ---> 68b9e843c428
Step 4/4 : RUN mkdir -p /var/run/sshd
 ---> Running in cda475eb7c81
Removing intermediate container cda475eb7c81
 ---> ec1cad7fa3c5
Successfully built ec1cad7fa3c5
Successfully tagged sneppets/sshd-example:latest

Also Read


Leave a Reply

Notify of