How to reduce the size of the generated Docker image with Spring Boot Maven plugin

Viewed 270

I love how you simply create a Docker image from a Spring Boot application with

mvn spring-boot:build-image

The only thing which bothers me is the size of the generated Docker. I have several applications between 500 and 900MB although they are not that different in dependencies.

Generating my own Docker script would probably allow me to finetune the generated image, but I'm wondering if there is some extra configuration that can be done in the pom-file to optimize the process.

This is my plugin config for the spring-boot-maven plugin:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <configuration>
         <image>
              <name>${project.artifactId}:${project.version}</name>
         </image>
         <layers>
              <enabled>true</enabled>
              <includeLayerTools>true</includeLayerTools>
         </layers>
    </configuration>
    <executions>
         <execution>
              <id>build-info</id>
              <goals>
                     <goal>build-info</goal>
              </goals>
         </execution>
    </executions>
</plugin>
0 Answers
Related