Unable to build docker image [duplicate] - docker

This question already has answers here:
docker: "build" requires 1 argument. See 'docker build --help'
(17 answers)
Closed 3 years ago.
i want to build a docker image. I do this:
$ docker build -f Dockerfile -t $IMAGE_TAG
I have this error:
"docker build" requires exactly 1 argument. See 'docker build --help'.
Usage: docker build [OPTIONS] PATH | URL | - Build an image from a
Dockerfile ERROR: Job failed: exit code 1

$ docker build -f Dockerfile -t $IMAGE_TAG .
The current directory dot . is missing at the end in your command line

Related

Why can't build the docker image?

I want to create a docker image according to the tutorial.create docker image
1.vim wechat.Dockerfile ,paste all lines into the file.
ls -al wechat.Dockerfile
-rw-r--r-- 1 debian debian 1217 Apr 29 10:21 wechat.Dockerfile
2.Build docker image with commands:
docker build -f "wechat.Dockerfile" --tag=wechat:0.0.1
Info:
"docker build" requires exactly 1 argument.
See 'docker build --help'.
Usage: docker build [OPTIONS] PATH | URL | -
Build an image from a Dockerfile
debian#debian:/tmp$ docker build -f wechat.Dockerfile --tag=wechat:0.0.1
"docker build" requires exactly 1 argument.
See 'docker build --help'.
Usage: docker build [OPTIONS] PATH | URL | -
Add . at the end of command:
docker build -f wechat.Dockerfile --tag=wechat:0.0.1 .
error checking context: 'can't stat '/tmp/systemd-private-ad10f6d540654f2791399efb421b6134-ModemManager.service-V2Upfj''.
No image 'wechat:0.0.1' created in current directory.
The command given is actually
docker build -f wechat.Dockerfile --tag=wechat:0.0.1 .
The final period is important, and denotes the current directory.

docker build command with variable in gitlab CI

I have following docker command in gitlab CI file .gitlab-ci.yml
docker build --pull -t "${CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG}" .
getting following error after build stage:
invalid argument "." for "-t, --tag" flag: invalid reference format
See 'docker build --help'.
any help , how to pass the variables ? Thanks
The way you've defined the tag is incorrect, and the result will be an empty string. That's why you get an error regarding the tag.
There is no need to add brackets, and you can use $ENV_VARIABLE. In this case, you can use the following command:
docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" .
If you want to use brackets:
docker build --pull -t "${CI_REGISTRY_IMAGE}:${CI_COMMIT_REF_SLUG}" .

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

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