#Step 1: build the image #build image will create war file , for running the war we need tomcat server. #docker build -t . #repository name must be in lower case
docker build -t docker-spring-tomcat .
docker image ls -a
#Step 3: Running a container from the image #Syntax: docker run -itd --name -p : image-name:tag
-d : represents (detached mode), note that if you don't run this in detached mode, the life of the container will be the life of the terminal in which you are executing it.
-p : represents the host-port to container-port mapping, if you substitute it with -P you will get a random port allocated by docker
docker run -itd --name spring-container -p 5555:8080 docker-spring-tomcat:latest
#Shows all the containers stopped and running docker ps -a
#Note: The container must be started before we can do this. docker exec -it /bin/bash
#Step 5: to check application on browser #http://localhost:5555/docker-spring-tomcat/ #5555 : exposed port over 8080