Docker With Spring Boot

10 03 2018

 

  1. Create Spring Boot Application

 

a.Use Spring Tool Suite (STS) to create spring boot application

Start New Project

 

 

b.Add Required Dependency

 

Here we add Actuator ,Web,Jercy(JAX-RS)

 

c. Click Finish.

 

 

2.Create Rest Service Class

 

3.Change POM File

 

 

 

 

 

 

4.Add Actuator and custom port

Note: This changes i added for , how to add custom port , instead of default port and to show all details in the actuator.

if you don’ t want to change this behaviour , in docker file just Change EXPOSE as 8080 and while running docker command give port as  -p  8080:8080.

server.port=8085

management.endpoints.web.exposure.include=*

 

5.Create Docker File

FROM openjdk:8

ADD target/docker-spring-boot.jar docker-spring-boot.jar

EXPOSE 8085

ENTRYPOINT ["java","-jar","docker-spring-boot.jar"]

6.mvn clean

7. mvn clean install

 

8.Build Docker

docker build -f Dockerfile -t docker-spring-boot .

9.Docker Images

docker images

10.Run Docker

docker run -p 8085:8085 docker-spring-boot

 

 

 

11.Check in Browser

12.Check Actuator

13.Check in Health Status

14.Check in Actuator Env

 

 

Source Code: https://github.com/mail2techsivam/docker-spring-boot

 

 

 

Advertisements




Tech Sivam Tips

13 07 2014

Hi All,

All My Old Posts are available in http://techsivamtips.wordpress.com/

Planning to post only technical things in this blog.

Thanks for your support.








%d bloggers like this: