Monday, June 10, 2019

STEPS TO CREATE AND DEPLOY IMAGE INTO DOCKER CONTAINER:



Steps are for deploying a SpringWebApp  in docker container

Prepare a file named "Dockerfile" with following green 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

No comments:

Post a Comment

Scrum and Scrum master

Scrum  Scrum is a framework which helps a team to work together.  It is like a rugby team (the scrum name comes from rugby game). Scrum enco...