Steps to deploy an Image in docker container



STEPS TO CREATE AND DEPLOY IMAGE INTO DOCKER CONTAINER

These steps are for creating image of simple Spring MVC WebApp
Create a file name "Dockerfile"  at the root of your webapp with following two line content:
FROM tomcat:8.0.20-jre8
COPY /target/myApplication.war /usr/local/tomcat/webapps/

To create a Docker Image open Terminal/command Prompt and then navigate to the project root directory and build the docker image
( You need to have docker installed on your system)
$ docker build -t myapp .

(don’t miss “.” , as it tells docker file is in current directory)

If the above command is successful then use
$ docker images
see if the image has been created.There should be a docker image called myapp

Run Docker Image
$ docker run -d  -p 8080:8080  --name mydockerapp myapp

If above command was successful use:
$ docker ps -a
it should show the running images

logs of a particular container
$ docker logs ContainerName/ContainerID

last 2500 lines of logs will be displayed
$ docker logs --tail 2500 ContainerName/ContainerID

First get the Timestamp format in logs using
$ docker logs --timestamps ContainerName/ContainerID

if only a day’s log needs to be viewed
$ docker logs --since 2017-05-03 ContainerName/ContainerID

if only a day’s log needs to be viewed since 10 am
$ docker logs --since 2017-05-03T10:00 ContainerName/ContainerID

stop the container
$ docker stop contaner_name/container_id

IP to access your deployed App
http://192.168.99.100:8080