1

So far, I user Spring Boot 2.2 and use jib to build a docker image.

But now, Spring Boot 2.3 released and the Release Notes says that Spring Boot 2.3 can build a Docker image with Paketo buildpack by default.

Spring Boot 2.3 enhances Docker support with new features This article says that Spring Boot 2.3 will allow for more efficient Docker builds.

I tried to build a docker image with Spring Boot 2.3. As bellow, Spring Boot 2.3 can build an image with some jvm options by default to optimize memory.

Container memory limit unset. Configuring JVM for 1G container.
Calculated JVM Memory Configuration: -XX:MaxDirectMemorySize=10M -XX:MaxMetaspaceSize=83555K -XX:ReservedCodeCacheSize=240M -Xss1M -Xmx453020K (Head Room: 0%, Loaded Class Count: 12338, Thread Count: 250, Total Memory: 1.0G)
Adding 127 container CA certificates to JVM truststore
Spring Cloud Bindings Boot Auto-Configuration Enabled

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \  
\\/  ___)| |_)| | | | | || (_| |  ) ) ) )
 '  |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot ::        (v2.3.1.RELEASE)

My Question: Is A docker image built by Spring Boot 2.3 better than the one by jib?

fanfanta
  • 181
  • 14

1 Answers1

1

Not better, but different. Jib can build the image without docker installation. Spring docker build unpack the jar (slightly better on startup) and put dependencies into a layer. When you build new version, it can reuse those layers (if dependencies not changed), so it just create one layer with your app (which size is way less then the dependencies' size). This cause that the build will be faster. But you have to install local docker.

zlaval
  • 1,941
  • 1
  • 10
  • 11
  • Thank you for your answer. Do both jib and Spring Boot 2.3 follow Dockerfile best practices? – fanfanta Aug 02 '20 at 05:09
  • 2
    By default, Jib does not use a fat jar to run spring boot apps. So there should be no difference in performance. Jib can also re-use layers if there are no changes in them. In fact these were all core principles of jib from the start. Everything in the answer above is true (and always has been ) for Jib. – loosebazooka Sep 25 '20 at 21:11