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

Actions

Information

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s




%d bloggers like this: