Many Java-based frameworks have been created since Spring Boot’s beginnings, but Spring Boot has become the standard to which all other frameworks are compared. The recent Spring Boot 2.3.0.M1 release brings with it some interesting new features that can help you package up your Spring Boot application into Docker images. This approach, leveraging Cloud Native Buildpacks, is more optimal than those used by many developers currently. This is because Spring Boot’s approach utilizes the concept of layered jars instead of a single jar.

Layering is designed to separate the code based on how likely it is to change between builds.  For example, this release provides the following layers out-of-the-box:

· dependencies (regular released dependencies)
· snapshot-dependencies (snapshot dependencies)
· resources (static resources)
· application (application classes and resources)

This allows for creating a multi-stage Dockerfile such as the following:

FROM adoptopenjdk:11-jre-hotspot as builder
WORKDIR application
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} application.jar
RUN java -Djarmode=layertools -jar application.jar extract

FROM adoptopenjdk:11-jre-hotspot
WORKDIR application
COPY –from = builder application/dependencies/ ./
COPY –from = builder application/snapshot-dependencies/ ./
COPY –from = builder application/resources/ ./
COPY –from = builder application/application ./

More info available at