Kasper
Kasper

Reputation: 320

I keep getting the "docker build" requires exactly 1 argument(s) error

First of, I am trying to follow along with this guide.

So far I have the host up and running, but I am stuck at this one point. I've installed the windowsservercore image, and I installed the IIS image and tagged it 'windowsserveriis'. Now I need to install ASP.NET 4.5, and I use the following command

docker build –t windowsserveriisaspnet .

I should maybe add that I create a folder for my Docker images. So I have a C:\dev\TestProject\DockerImages and the a folder for each Dockerfile. Now, I am a bit unsure about this, as the guide never mentions how to actually create the files, so I thought I would divide them up just to be safe (and also be able to have them be named just 'Dockerfile' to avoid confusion).

Anyways, the above command prints out the following error message:

docker : "docker build" requires exactly 1 argument(s).

At line:1 char:1

docker build –t windowsserveriisaspnet .

My Dockerfile looks like this:

FROM windowsserveriis

RUN dism /online /enable-feature /featurename:IIS-ASPNET45

My initial thought was that i forgot the dot at the end, but that is not the case. I also tried replacing the dot with '--file="DockerfileASPNET"' (where I renamed the file). However nothing seems to work.

So, what am I missing? Thanks in advance..

Upvotes: 16

Views: 35823

Answers (10)

SREELEKSHMI G
SREELEKSHMI G

Reputation: 1

I was facing the same issue and the problem was that I missed the . at the end.

docker image build -t repo/learn:23 .

It basically points to the current working directory. so now it know from where to pick the Dockerfile

Upvotes: 0

attila9778
attila9778

Reputation: 11

For me inspecting label values gave the answer. Some of the values contained a space character. Putting that value between " " solved the issue.

Upvotes: 0

mattocaramba
mattocaramba

Reputation: 127

At the time of writing the (copy&paste) error hasn't been recorded here - the error is in the em/en dash character.

One of these commands is wrong.

This has the wrong char i.e. –

docker build –t windowsserveriisaspnet .

While this has the correct one i.e. -

docker build -t windowsserveriisaspnet .

Upvotes: 1

vishy dewangan
vishy dewangan

Reputation: 1069

Basically i used to think that using switch -f or --file, it does not require the additional input of Dockerfile Path. But it requires it at the end.So cmd should be

"$docker build --tag REPO-NAME:TAG-NAME --file FILEPATH DIRPATH

Upvotes: 1

Kasper
Kasper

Reputation: 320

Turns out there was some hidden formatting in my command. If I wrote it out manually, instead of copy/pasting, it worked. So I guess the lesson learned here is; check your copying.

Upvotes: 4

Mohsin Latif
Mohsin Latif

Reputation: 505

I was facing the same issue. I missed the little period ( . ) at the end of the command. I copy pasted the command from official docker docs. The period ( . ) at the end of the command tells Docker to use the shell’s current working directory as the build context. Be sure include the period (.) at the end of the command, and be sure to run the command from the current working directory that contains the Dockerfile and application code.

Upvotes: 34

Kapil Shewate
Kapil Shewate

Reputation: 51

I have also faced the same issue when I copy pasted the given command. However, it worked when I typed the same command given below.

$ docker image build -t python-hello-world .

Upvotes: 5

sayonaraa1
sayonaraa1

Reputation: 384

Try in this format

docker build --pull -t windowsserver . -f <path where dockerfile is present>

Upvotes: 1

Uddhav P. Gautam
Uddhav P. Gautam

Reputation: 7626

Docker build requires docker file.

Note: you must provide URL or path where you store your built docker image file. You missed providing the URL or path

SYNTAX: docker image build OPTIONS <url or path>

Solution commands (in 2 ways)

  1. docker image build -f <dockerfile> <url or path>
  2. docker build -f <dockerfile> <url or path>

Eg, docker build --file ./Dockerfile.txt .

Upvotes: 9

Robert Ostrowicki
Robert Ostrowicki

Reputation: 362

If .Dockerfile is in your current directory use:

docker build –t windowsserveriisaspnet -f ./.Dockerfile .

So you point to the specific file -f ./.Dockerfile and need to point to local folder using . (dot at the end).

Upvotes: 2

Related Questions