“docker build” requires exactly 1 argument - docker

I know there are several posts like this but nothing has worked so far, I have a Dockerfile inside a folder and I have tried the following commands:
docker build <full/path> --label test1="test2" --tag myImage
docker build --file <full/path>/Dockerfile --label test1="test2" --tag myImage
docker build Dockerfile --label test1="test2" --tag myImage <full/path>
docker build --label test1="test2" --tag myImage --file <full/path>/Dockerfile
docker build Dockerfile --label test1="test2" --tag myImage .
But I always get this error docker build" requires exactly 1 argument.
Strangely enough this only happens with an specific Dockerfile, I have another one in a similar folder structure and that one works fine:
/folder1
/folder2
Dockerfile // This one works
more files...
/folder3
Dockerfile // This one fails
more files...
Notice that I'm not running the commands from that same folders so I have to use absolute paths (since I'm running the commands from Java API) but it is still strange that one Docker file works and the other one fails since the folder structure is the same.

So what I know is that optional arguments have to be BEFORE the only argument.
The only argument is your dockerfile / your path to the lockerfile.
docker build --label "test1=test2" --tag "myImage" .

Related

How to specify GIT_ACCESS_TOKEN for the docker build command?

I run this command
docker build GIT_ACCESS_TOKEN=my_token -t "${IMAGE}" .
and got this error
"docker build" requires exactly 1 argument.
See 'docker build --help'.
Usage: docker build [OPTIONS] PATH | URL | -
Build an image from a Dockerfile
But as you see above, I do have a dot at the end of the docker build command. Besides, docker build . -t "${IMAGE}" works for me, so it seems the error is introduced at GIT_ACCESS_TOKEN part?
Are you looking for build-arg?
docker build --build-arg GIT_ACCESS_TOKEN=my_token -t "${IMAGE}" .

Cannot run an image in Docker

I created an image called "helloworld" based on some project I have.
If I run :
docker images
I can see it there on top of the list.
Now if I want to run it, docker complains it does not exist.
Running this :
docker run -p 8080:8080 helloworld
returns this :
docker: Error response from daemon: pull access denied for helloworld,
repository does not exist or may require 'docker login': denied:
requested access to the resource is denied. See 'docker run --help'.
Why is docker complaining that my image does not exist?
It complains, because this:
docker run -p 8080:8080 helloworld
is a shortened version of this:
docker run -p 8080:8080 docker.io/library/helloworld:latest
and, based on the screenshot, your image is called
docker.io/library/helloworld:1.0
so the proper command (skipping default prefix) is:
docker run -p 8080:8080 helloworld:1.0
Other answers are correct but don't explain clearly why they are correct.
The docker run command expects an image name and, optionally, a tag (i.e., docker run IMAGE[:TAG]). If a tag is not provided, the default is latest.
Running docker run helloworld is equivalent to docker run helloworld:latest, but this image does not exist in the OP's system according to docker images.
The solution is to specify the image tag: helloworld:1.0.
Your image build command:
docker build --rm -f "Dockerfile" -t helloworld:1.0 "."
Meaning your image name is helloworld:1.0
If you had run docker build --rm -f "Dockerfile" -t helloworld "."
Then your image name is helloworld or helloworld:latest and your first try would have worked.
To solve your issue run this instead:
docker run -p 8080:8080 helloworld:1.0

Why isn't docker recognizing my "-f" option?

Following this post -- docker: "build" requires 1 argument. See 'docker build --help', I'm trying to build my docker image using a file with a non-traditional name ("local.Dockerfile") on Mac 10.13.6. I tried the below
localhost:mydir davea$ docker build -t mycontainer -f local.Dockerfile
"docker build" requires exactly 1 argument.
See 'docker build --help'.
Usage: docker build [OPTIONS] PATH | URL | -
Build an image from a Dockerfile
But docker is choking on me. I'm running version 19.03.5.
Basic command to build docker image:
docker build -t <image_tag> -f <Dockerfile_name> <Path_of_Dockerfile>
So you are missing to specify the path of your local.Dockerfile (which is mandatory). If your dockerfile is in the current directory from where you are running the command, then run below command, else update the path accordingly:
docker build -t mycontainer -f local.Dockerfile .
Note: You can specify the Path_of_Dockerfile in any way: relative path or absolute path, whichever way you feel comfortable.

Docker build,where to run?

I am learning Docker
docker build -t mm/cowsay .
Should I go to cowsay folder or should I run it from my home mm directory?
I have registered on Docker hub.
The docker build command follows instructions specified in a given Dockerfile, and outputs an image.
Syntax:
docker build \
-t <tag-of-output-image> \
-f <path-to-dockerfile>
If you use . instead of -f <path-to-dockerfile>, you are telling the Docker Engine to use the Dockerfile in the current directory.
So you need to run your command from where the Dockerfile exists.

Docker build dockerfile

I am trying to build a docker image from dockerfile which I have written.
docker build -f ~/www/node-beta.dockerfile
This however results in the error:
docker: "build" requires 1 argument. See 'docker build --help'.
The docker build command always requires a location argument. In this case you should use ~/www/ as the for the location argument, and the file name, "node-beta.dockerfile" for the -f (filename) argument.
docker build -f node-beta.dockerfile ~/www
sudo docker build -t yee/haw -f ~/www/node-beta.dockerfile ~/www/

Resources