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

30,899

Solution 1

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.

Solution 2

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.

Solution 3

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 .

Solution 4

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 .

Solution 5

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).

Share:
30,899

Related videos on Youtube

Kasper
Author by

Kasper

Updated on July 09, 2022

Comments

  • Kasper
    Kasper almost 2 years

    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..

    • Dani
      Dani over 7 years
    • Dani
      Dani over 7 years
      There are more answers. Also, you should google it, and if you tried that question, you should mention it. It will save everyone time, as you can now tell.
    • Mike Garuccio
      Mike Garuccio
      @alldani He already has the . in his code so that answer is not relevant. @kasper where are you running the command from? are you inside the folder you created to house the Dockerfile? Also make sure your Dockerfile is named Dockerfile with correct capitalization
  • kolexinfos
    kolexinfos over 5 years
    After trying everything, the only thing that worked for me in Powershell was typing it out
  • spencer.sm
    spencer.sm almost 5 years
    And don't forget to include the period (.) at the end ;)
  • Luciano Ghilarducci
    Luciano Ghilarducci about 4 years
    NUB mistake! LOL! (I did the same!)
  • agileDev
    agileDev over 3 years
    Yes but it's not only (.) at the end but a space and (.) at the end worked for me.