Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"docker build" requires exactly 1 argument(s)

I am trying to build an image from a specific Dockerfile, and tag it at the same time; I am following the online instructions fordocker build, but I get the following error:

"docker build" requires exactly 1 argument(s)

My directory structure:

project/     foo/     MyDockerfile 

This is the command I run:

docker build -f /full/path/to/MyDockerfile -t proj:myapp

I have tried various combinations of the above command, but the results are always the error message given above. Why is this happening - as I am following what the documentation says?

like image 479
Homunculus Reticulli Avatar asked Oct 01 '17 21:10

Homunculus Reticulli


People also ask

What is the dot in docker build?

There is a “.” (dot) at the end of the command (which is an alias for $PWD current directory). This tells docker the that the resources for building the image are in the current directory. By default, when you run the docker build command, it looks for a file named Dockerfile in the current directory.

What is a docker build?

Description. The docker build command builds Docker images from a Dockerfile and a “context”. A build's context is the set of files located in the specified PATH or URL . The build process can refer to any of the files in the context. For example, your build can use a COPY instruction to reference a file in the context ...

What is docker argument?

You can use the ARG command inside a Dockerfile to define the name of a parameter and its default value. This default value can also be overridden using a simple option with the Docker build command.

How do I tag in docker?

Docker tags are just an alias for an image ID. The tag's name must be an ASCII character string and may include lowercase and uppercase letters, digits, underscores, periods, and dashes. In addition, the tag names must not begin with a period or a dash, and they can only contain 128 characters.

Does'Docker build'require exactly 1 argument (s)?

"docker build" requires exactly 1 argument(s) 14 I keep getting the "docker build" requires exactly 1 argument(s) error 25 Jenkins Pipeline docker.build() gives error '"docker build" requires exactly 1 argument(s)'

How many arguments are required to build a docker image?

docker: "build" requires 1 argument. See 'docker build --help' - Stack Overflow Trying to follow the instructions for building a docker image from the docker website.

How do I get the build context of a docker build?

After docker parses all of the flags for the command, there should be one argument left when you're running a build. That argument is the build context. The standard command includes a trailing dot for the context: sudo docker build -t myrepo/redis . What's the build context? Every docker build sends a directory to the build server.

How do I build a dockerfile in local directory?

You need to add a dot, which means to use the Dockerfile in the local directory. docker build -t mytag . It means you use the Dockerfile in the local directory, and if you use docker 1.5 you can specify a Dockerfile elsewhere.


2 Answers

Parameter -f changes the name of the Dockerfile (when it's different than regular Dockerfile). It is not for passing the full path to docker build. The path goes as the first argument.

Syntax is:

docker build [PARAMS] PATH

So in your case, this should work:

docker build -f MyDockerfile -t proj:myapp /full/path/to/

or in case you are in the project directory, you just need to use a dot:

docker build -f MyDockerfile -t proj:myapp .

like image 98
Krzysztof Atłasik Avatar answered Sep 30 '22 14:09

Krzysztof Atłasik


docker build .

DO NOT MISS "THE DOT".

like image 26
best wishes Avatar answered Sep 30 '22 12:09

best wishes