"docker build" requires exactly 1 argument(s)

DockerDockerfile

Docker Problem Overview


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?

Docker Solutions


Solution 1 - Docker

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 .

Solution 2 - Docker

> docker build .

DO NOT MISS "THE DOT".

Solution 3 - Docker

A. Please upvote Krzysztof's answer. I was lost without his hints.

But B, my contribution.

I was able to use a full path for the --file argument.

docker build --build-arg JAR_FILE="/source/java/mystuff/build/libs/mything-1.0.10-SNAPSHOT.jar" --file /full/path/to/MyDockerfile -t proj:myapp .

I had forgotten that little "." at the end.

D'oh!

Aka, do NOT overlook the last little "." (period) at the end !!!

Solution 4 - Docker

sudo docker build -t my-app .

Don't forget to add DOT at the end.

reference: https://docs.docker.com/get-started/02_our_app/

Solution 5 - Docker

docker built . -t my-app

docker build

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionHomunculus ReticulliView Question on Stackoverflow
Solution 1 - DockerKrzysztof AtłasikView Answer on Stackoverflow
Solution 2 - Dockerbest wishesView Answer on Stackoverflow
Solution 3 - DockergranadaCoderView Answer on Stackoverflow
Solution 4 - DockerSoubhagya Kumar BarikView Answer on Stackoverflow
Solution 5 - DockerDoveView Answer on Stackoverflow