Minimal Docker Images for Java Applications

Minimal Linux Images

Although Alpine is incredibly small, Debian’s official slim version of Stretch is now down to 55.3MB. Compare this to the Ubunto 17.10 image with 96.8MB! And while tklx/base and bitnami/minideb are a little smaller, I don’t think that 2.5MB in reductions is relevant enough to replace the official Debian image.

An interesting approach was taken by blitznote/debase. Getting rid of systemd and unnessecary tools for file system management reduces the images size to an impressive 39.1MB. Without apt the base image of blitznote is even smaller, weighing only 24.2MB.

This is the smallest Debian based Docker image that I know of!

But since Alpine comes with a decent package management system, comparing it to blitznote/baseimage would be unfair.

REPOSITORY          TAG            IMAGE ID       CREATED       SIZE
alpine              3.7            3fd9065eaf02   7 weeks ago   4.15MB
blitznote/baseimage latest         49db5d90d6f1   4 months ago  24.2MB
blitznote/debase    17.10          57480094f18e   22 hours ago  39.1MB
tklx/base           stretch        6a795babcd50   9 months ago  52.8MB
bitnami/minideb     stretch        774c45746016   44 hours ago  53.7MB
debian              stretch-slim   87afbf13bea7   2 weeks ago   55.3MB

However, the difference in size between Alpine and a stripped down Debian image is now 35MB for blitznote/debase and 51MB for the official Debian image. After adding a JVM and an application server – even if it’s just Tomcat, TomEE or Payara Micro – the difference becomes even less significant.

On the other hand Debian provides access to a massive repository of stable software packages, all ready to be installed right away. This is a big advantage over Alpine.

Other Small Linux Images

REPOSITORY          TAG            IMAGE ID       CREATED       SIZE
ubuntu              17.10          a8ad041f5225   5 weeks ago   96.8MB
oraclelinux         7-slim         9870bebfb1d5   3 months ago  118MB

Minimal Java Images Based on Alpine

I’m focussing on images that provide a JDK, not just a JRE.

REPOSITORY                 TAG          IMAGE ID     CREATED     SIZE
anapsix/alpine-java        8_server-jre 5bad6c4badbb 5 days ago  125MB
jeanblanchard/java         serverjre-8  663a167a094b 6 weeks ago 162MB
frolvlad/alpine-oraclejdk8 cleaned      99bce0d7a184 5 days ago  171MB

Small Java Images Based on Debian

REPOSITORY                 TAG                      IMAGE ID     SIZE
dhyanb/debase-serverjre    8                        523b72c96aa7 172MB
dhyanb/deb-slim-serverjre  8                        6ea94448cbc9 198MB
openjdk                    8u151-jdk-slim-stretch   52de5d98a41d 244MB
store/oracle/serverjre     8                        d747305fda45 280MB

By using blitznote/debase as a base image and aggressively removing unnecessary .jar and other files from the JRE, I managed to bring the image size down to 172MB. While the smallest Alpine based Java image is only 125MB in size, both images are now playing in the same league. Considering compatibility and availability of software packages I think that Debian is a very attractive alternative to Alpine.