We are upgrading our microservices in docker to use Java 17 and previously we used the base image openjdk:11-jre-slim. What is the corresponding image for Java 17?
There doesn't seem to be a openjdk:17-jre-slim? In fact there dont seem to be any recent jre images - just jdks. The 11-jre-slim image seems to be arount 75MB - is there a suitable similarly sized Java 17 image?
We have also used alpine images in the past too.
openjdk:<version>-alpine This image is based on the popular Alpine Linux project, available in the alpine official image.
openjdk:<version>-slimIt only contains the minimal packages needed to run Java. Unless you are working in an environment where only the openjdk image will be deployed and you have space constraints, we highly recommend using the default image of this repository. Follow this answer to receive notifications.
OpenJDK is the official reference implementation of Java SE since version 7. Java is a registered trademark of Oracle and/or its affiliates. The most straightforward way to use this image is to use a Java container as both the build and runtime environment.
Work through the orientation and setup in Get started Part 1 to understand Docker concepts. Refer to the following section for Java prerequisites. Before we start building images, ensure you have enabled BuildKit on your machine. BuildKit allows you to build Docker images efficiently. For more information, see Building images with BuildKit.
Before you could build a Docker image with a size of less than 80MB – this was easily achieve with a multi-stage Docker build. In the meantime the only choice for building a JRE is to use jlink. The Eclipse Foundation seems to be developing a JRE for Java 17 after a lot of feedback from the community.
The OpenJDK binaries in the default image as well as the -oracle and -oraclelinux7 variants are built by Oracle and are sourced from the OpenJDK community. These binaries are licensed under the GPLv2 with the Classpath Exception. This image is based on the popular Alpine Linux project, available in the alpine official image.
Oracle image is freely available from Java-17 openjdk:17-oracle
Dockerfile:
FROM openjdk:17-oracle
openjdk:17-jdk-slim
also creates lightweight image
Dockerfile:
FROM openjdk:17-jdk-slim
You can try this (eclipse-temurin:17-jre-alpine
) which is around 50MB of compressed size
https://hub.docker.com/layers/eclipse-temurin/library/eclipse-temurin/17-jre-alpine/images/sha256-839f3208bfc22f17bf57391d5c91d51c627d032d6900a0475228b94e48a8f9b3?context=explore
I couldn't sill find an OpenJDK jre image
If you are looking for the tiniest Docker images with Alpine Linux and OpenJDK, have a look at Liberica JDK containers at DockerHub https://hub.docker.com/r/bellsoft/liberica-openjdk-alpine The images have Alpine and Liberica Lite, which is optimized in size to be used on microservices. It is also recommended by the Spring team https://spring.io/quickstart
An update on this - looking again at the Eclipse Adoptium issue mentioned above (https://github.com/adoptium/temurin-build/issues/2683) the more recent comments indicate they have now started producing JRE images.
We have switched to using eclipse-temurin:17-jre-focal
. There is also a (slightly larger) 17-jre-centos7
and a smaller 17-jre-alpine
, but we now need some libraries that aren't in alpine.
In your Dockerfile link:
FROM openjdk:17-alpine
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With