-1

I have a dockerfile that is suppsed to start the tomcat. I want to create and not run the image from that dockerfile so that in docker images I can see the image. docker run -it logs me in to container but I dont want to create container and log in to it.

I just want to create a image from dockerfile (without creating a container of it).

By which command can I achieve this ?

solveit
  • 869
  • 2
  • 12
  • 32

3 Answers3

3

SOLUTION 1: Just run docker build -t my-new-image .
This command will tag image with name you provide.

SOLUTION 2: command docker build . will create <none> image (check docker images output image will be created with image ID ). You can tag this image manually with any image name by command:
docker tag <IMAGE-ID> my-image-name

gaurav sinha
  • 156
  • 6
2

That would be the build command.

https://docs.docker.com/engine/reference/commandline/build/

im_baby
  • 912
  • 1
  • 8
  • 14
0

Run docker build -t <yourImageName> -f <yourDockerfileName> . Or just simply docker build .

Don't forget to add the "dot" at the end. It specifies where to find the files for the “context” of the build.

czende
  • 837
  • 5
  • 10
  • @czende-:: docker build -t myimage -f . gives the error "docker build require exactly 1 argument" and "docker build . " command is building the image successfully but in "docker images" command I am not able to see the image – solveit Aug 09 '21 at 13:31
  • The `-f` option isn't needed if the file is named exactly `Dockerfile` and is in the `.` directory. – David Maze Aug 09 '21 at 14:05