“docker build” requires exactly 1 argument(s)

2020-08-11 17:14发布

问题:

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?

回答1:

Parameter -f changes name of the Dockerfile (when it's different than regular Dockerfile). It is not for passing full path to docker build. Path goes as 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 project directory, you just need to use a dot:

docker build -f MyDockerfile -t proj:myapp .