Run Spring Boot in a Docker container with debug and Spring profiles support

Spring Boot & Docker with debug and Spring profiles

Spring Boot and Docker are extremely popular. The Spring Boot adoption now hits 34% according to this survey: http://www.baeldung.com/java-8-spring-4-and-spring-boot-adoption. Docker adoption has more than doubled from 13% to 27% in 2016 according to a RightScale survey.

Spring Boot helps application development process while Docker contributes to streamline deployment.

The spring-boot-docker image will help you run your Spring Boot applications with Docker, either in development or production stage.

Features of spring-boot-docker image

Although there are many images for this purpose, this one provides two useful features:

Easily debug your application

Simply set the variable DEBUG to true in docker-compose.yml file and the application will start in debug mode:

environment: 
- "DEBUG=true"

Run your application with desired Spring profile

Spring profiles are a useful way to separate applications resources between different stages. To specify a Spring profile your application should run with, simply set the  SPRING_PROFILES_ACTIVE variable in docker-compose.yml:

environment:
 - "SPRING_PROFILES_ACTIVE=dev"

To run the application within the Docker container, simply place your executable jar into the assets directory, renamed as follows: spring-boot-application.jar.

Then launch the container:

docker-compose up -d

More instructions are available here: https://github.com/f-lopes/spring-boot-docker