I am trying to build an image from a specific Dockerfile, and tag it at the same time; I am following the online instructions fordocker build
, but I get the following error:
"docker build" requires exactly 1 argument(s)
project/ foo/ MyDockerfile
This is the command I run:
docker build -f /full/path/to/MyDockerfile -t proj:myapp
I have tried various combinations of the above command, but the results are always the error message given above. Why is this happening - as I am following what the documentation says?
There is a “.” (dot) at the end of the command (which is an alias for $PWD current directory). This tells docker the that the resources for building the image are in the current directory. By default, when you run the docker build command, it looks for a file named Dockerfile in the current directory.
Description. The docker build command builds Docker images from a Dockerfile and a “context”. A build's context is the set of files located in the specified PATH or URL . The build process can refer to any of the files in the context. For example, your build can use a COPY instruction to reference a file in the context ...
You can use the ARG command inside a Dockerfile to define the name of a parameter and its default value. This default value can also be overridden using a simple option with the Docker build command.
Docker tags are just an alias for an image ID. The tag's name must be an ASCII character string and may include lowercase and uppercase letters, digits, underscores, periods, and dashes. In addition, the tag names must not begin with a period or a dash, and they can only contain 128 characters.
"docker build" requires exactly 1 argument(s) 14 I keep getting the "docker build" requires exactly 1 argument(s) error 25 Jenkins Pipeline docker.build() gives error '"docker build" requires exactly 1 argument(s)'
docker: "build" requires 1 argument. See 'docker build --help' - Stack Overflow Trying to follow the instructions for building a docker image from the docker website.
After docker parses all of the flags for the command, there should be one argument left when you're running a build. That argument is the build context. The standard command includes a trailing dot for the context: sudo docker build -t myrepo/redis . What's the build context? Every docker build sends a directory to the build server.
You need to add a dot, which means to use the Dockerfile in the local directory. docker build -t mytag . It means you use the Dockerfile in the local directory, and if you use docker 1.5 you can specify a Dockerfile elsewhere.
Parameter -f
changes the name of the Dockerfile (when it's different than regular Dockerfile
). It is not for passing the full path to docker build
. The path goes as the first argument.
Syntax is:
docker build [PARAMS] PATH
So in your case, this should work:
docker build -f MyDockerfile -t proj:myapp /full/path/to/
or in case you are in the project directory, you just need to use a dot:
docker build -f MyDockerfile -t proj:myapp .
docker build .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With