“Docker build” requires exactly 1 argument [How to Solve]

Background

Recently, we need to use dockerfile to build the image. The documents we found are as follows

https://yeasy.gitbooks.io/docker_ practice/content/image/build.html

$ docker build -t nginx:v3 .
Sending build context to Docker daemon 2.048 kB
Step 1 : FROM nginx
 ---> e43d811ce2f4
Step 2 : RUN echo '<h1>Hello, Docker!</h1>' > /usr/share/nginx/html/index.html
 ---> Running in 9cdc27646c7b
 ---> 44aa4490ce2c
Removing intermediate container 9cdc27646c7b
Successfully built 44aa4490ce2c

Press the prompt to report an error

$ docker build -t centos_base:v1
"docker build" requires exactly 1 argument.
See 'docker build --help'.

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

Build an image from a Dockerfile

It feels like there’s something fishy going on here~

Resolution

Following the standard process of problem solving  one word at a time, I found a point at the end

Followup

I found this description in the official documentation

https://docs.docker.com/engine/reference/commandline/build/ This example specifies that the PATH is ., and so all the files in the local directory get tard and sent to the Docker daemon. The PATH specifies where to find the files for the “context” of the build on the Docker daemon. Remember that the daemon could be running on a remote machine and that no parsing of the Dockerfile happens at the client side (where you’re running docker build). That means that all the files at PATH get sent, not just the ones listed to ADD in the Dockerfile.

# USAGE
docker build [OPTIONS] PATH | URL | -
# e.g.
docker build .

That is to say, in the official document example, Path indicates . , and then many files in the current directory are sent to the docker’s daemons, Path specifies the path to find files in context when building the image. For example, the first parameter of the Add instruction in dockerfile can be found from the context, that is, the file just sent to docker daemon

Similar Posts: