docker build -t serendipity111011/repo-name:latest -t serendipity111011/repo-name:$SHA -f ./Apollo API/Dockerfile ./Apollo API
I am trying to run the above command to build docker image and I am getting below error
invalid argument "serendipity111011/repo-name:" for "-t, --tag" flag: invalid reference format
What am I doing wrong?
It was actually due to stupidity on my part. You have to escape the space correctly when you write out build commands like below
docker build -t serendipity111011/repo-name:latest -t serendipity111011/repo-name:$SHA -f ./Apollo\ API/Dockerfile ./Apollo\ API
I hope it helps someone who might be having same issue.
Related
Here is a shell script used in Jenkins. The $version should be replaced with the set parameter in Jenkins.
docker build -t gitlab.x.com:3030/directory:$version -f windows-config/backend/Dockerfile .
I want to run it on powershell but the logs says "invalid argument "gitlab.x.com:3030/directory:" for "-t, --tag" flag: invalid reference format."
It probably is a syntax problem with the $version
I tried changing it to
docker build -t 'gitlab.x.com:3030/directory:$version' -f windows-config/backend/Dockerfile .
but the logs say ""docker build" requires exactly 1 argument. See 'docker build --help'."
I'm trying to create a docker image using this command (removed the address as it's a company address):
docker build -f Dockerfile.web --build-arg _env=MTP-uat1 . -t Company/address:NlLogDownloadAl
But I keep getting this error:
failed to solve with frontend dockerfile.v0: failed to read dockerfile: open /var/lib/docker/tmp/buildkit-mount745508724/Dockerfile.web: no such file or directory
Now I've gone through like 30 similar questions and followed what they say would fix it but it does no difference.
I have done the following:
Changed the docker engine script buildkit from true to false.
Made sure the directory I'm referring to has the Dockerfile.web file.
Removed some things mentioned from the .dockerignore file.
I still get the same error all the time. Why?
The last part of the command has to be context (the directory where Docker should look for files / "the dot"):
Usage: docker build [OPTIONS] PATH | URL | -
Try this one:
docker build \
-f Dockerfile.web \
--build-arg _env=MTP-uat1 \
-t Company/address:NlLogDownloadAl \
.
You are getting no such file or directory because you haven't specified the context properly, thus it probably cut off the last argument of the command Company/address:NlLogDownloadAl (or its part), treated it as a folder which probably doesn't even exist and then it tried to look up for Dockerfile.web which wouldn't exist too either due to invalid folder or just because of the wrong folder specified.
I look a sample
Dockerfile
ARG some_variable_name
# or with a default:
# ARG some_variable_name=default_value
RUN echo "Oh dang look at that $some_variable_name
# or with ${some_variable_name}
docker build
$ docker build --build-arg some_variable_name=a_value
result
Oh dang look at that a_value
but, I used the sample always gets error
"docker build" requires exactly 1 argument.
See 'docker build --help'.
Usage: docker build [OPTIONS] PATH | URL | -
Build an image from a Dockerfile
Why? Was I lose something?
in addition to #Ridwan answer, MAKE SURE THERE IS NO ADDITIONAL WHITE SPACE IN BETWEEN
docker build -t mytag .
You seem to have forgotten to put a dot, which represents that the Dockerfile in the local directory.
By that I meant:
docker build -t mytag .
What you were previously doing was:
docker build -t mytag
Thus forgetting to put the dot.
I did my research and based on the links here and here I would assume that running this command docker.build("tas/tuya-message-listener-china:${env.BUILD_NUMBER}", "--build-arg jar=tuya-message-listener-ecs-china.jar .") would have worked, but what I get is this in the output
21:36:48 + docker build -t --build-arg jar=tuya-message-listener-ecs-china.jar tas/tuya-message-listener:27 .
21:36:48 invalid argument "--build-arg" for "-t, --tag" flag: invalid reference format
21:36:48 See 'docker build --help'.
So where do I go wrong?
When I run this command on my gitlab pipeline
docker build --build-arg NPM_TOKEN=${NPM_TOKEN} --tag $REGISTRY_IMAGE/web-public:$CI_COMMIT_SHA --tag $REGISTRY_IMAGE/web-public:$CI_COMMIT_REF_NAME packages/web-public
it fails with
build requires exactly 1 argument
It looks to me like I am actually passing one argument, the path; packages/web-public. Flags are not arguments as far as I know.
What am I missing here?
This is the structure of my project
Quote your variables. Something in those variables is expanding to be more than the single arg to the flag.
docker build --build-arg "NPM_TOKEN=${NPM_TOKEN}" --tag "$REGISTRY_IMAGE/web-public:$CI_COMMIT_SHA" --tag "$REGISTRY_IMAGE/web-public:$CI_COMMIT_REF_NAME" packages/web-public
You can also echo that command to see how the variables are expanding, e.g.
echo docker build ...
from https://docs.docker.com/engine/reference/commandline/build/
docker build [OPTIONS] PATH | URL | -
It looks like there's something wrong with your PATH. Try using the absolute path or change to the directory containing the Dockerfile and use .
see also: "docker build" requires exactly 1 argument(s)
My issue was that I had a multi line script entry, eg
script:
- >
docker build \
--network host \
-t ${CI_REGISTRY}/kylehqcom/project/image:latest \
....
As soon as I added to a single line, we were all ok. So I guess the line breaks got "entered" after the first line which meant that the subsequent lines were ignored and the error was returned. Also note, that I CI linted via the GitLab ui and all was syntactically correct.