Docker for Spring Boot
A Docker image to create Spring Boot based containers in a jiffy.
Although running Spring Boot executable jars under Docker is quite straightforward this image provides with some nice features:
- Run from a light Java 8 image
- Use a normal user instead of
/dev/randomto fix startup issues
- Add the executable jar as well as any configuration
Creating a derived image is a two step process:
- Create a
- Put the application
Create a minimal
Dockerfile for instance:
FROM ggtools/spring-boot MAINTAINER Your Name <email@example.com>
Spring Boot Application directory
Dockerfile expects the executable jar to be named
spring-boot-app.jar and to be located under the
spring-boot-app/lib directory. The second step would be to create the directory and copy the executable jar into it.
In addition to the jar the image will also include any file located under the
spring-boot-app/config directory. According to Spring Boot documentation on Externalized Configuration the configuration files located in this directory will take precedence over the configuration files in the application jar.
The default behavior can be customized using environment variables:
SB_APP_JARto change the name of the application jar (default
SB_ACTIVE_PROFILESto select the active profiles (default
The image is distributed under the MIT license.