docker-library / openjdk

Docker Official Image packaging for EA builds of OpenJDK from Oracle
http://openjdk.java.net
MIT License
1.14k stars 471 forks source link

Add java 17 JRE slim image #468

Closed pjroth closed 2 years ago

pjroth commented 2 years ago

When creating a docker image to run a java program, it is desirable to us that the image is as small as possible. This is to speed up build and launch times mainly. This is especially important when caching is not able to help such as on ephemeral build instances or production execution environments. The build image when we upgraded from 11 to 17 is about twice the size. It would be nice if the image was similar to the 11 image, perhaps by creating a JRE only java 17 image such as 17-jre-slim. This JRE image is what we used when we were running java 11.

11 vs 17 image size comparison:

# docker images |grep -e 11-jre-slim -e 17-slim
openjdk                  17-slim                   87a856efdb51   10 hours ago    407MB
openjdk                  11-jre-slim               973c18dbf567   16 months ago   204MB

Thank you!

wglambert commented 2 years ago

See https://github.com/docker-library/openjdk/issues/272 The builds come from https://jdk.java.net/17/ which only offers the JDK

https://github.com/docker-library/openjdk/issues/302#issuecomment-482722509

Upstream does not distribute an official JRE package that I am aware of, nor do they have documentation for either what bits from the official downloads should be kept or what bits should be removed to create an official JRE package, so this will not involve that. (Folks wishing to create a JRE based on OpenJDK 12+ are likely better off playing with jlink anyhow to create their own custom minimal JRE via a multi-stage build or similar -- I've personally done so via the existing Oracle Linux image with a multi-stage build copying the resulting minimal JRE into a Debian-based image with great success.)

pjroth commented 2 years ago

Thanks for the quick answer. Seems like this should be closed then?