Video in progress

What is the difference between alpine, distroless and a regular Debian/Ubuntu-based JRE when choosing a base image for a Java service?

Size (approx.) / Strength / Pain — eclipse-temurin:21-jre (Ubuntu): ~200 MiB / glibc, shell, the usual tools / more packages, more CVEs; eclipse-temurin:21-jre-alpine: ~100 MiB / small / musl, differences in DNS and native libs; distroless java: ~150 MiB / no shell, small attack surface / you cannot get inside with…

📖 Answer

Image Size (approx.) Strength Pain
eclipse-temurin:21-jre (Ubuntu) ~200 MiB glibc, shell, the usual tools more packages, more CVEs
eclipse-temurin:21-jre-alpine ~100 MiB small musl, differences in DNS and native libs
distroless java ~150 MiB no shell, small attack surface you cannot get inside with kubectl exec

Practical problems with Alpine: Netty's native transport, some JDBC drivers, gRPC, and compression libraries such as Snappy/LZ4 may be built for glibc. musl's DNS resolver also behaves differently. Everything may work, but you will see more bugs of the "worked on my laptop, not in prod" kind.

With distroless, the lack of sh gets in the way both of writing sleep in preStop and of calling jcmd inside. For debugging, you attach an ephemeral container with kubectl debug.

The biggest size win often comes not from the base image but from a runtime built with jlink from only the needed modules. But every time you add a new dependency, you must update the module list.

I usually start with the Temurin JRE (Ubuntu), and move to distroless where the security requirement is strong.