I'm trying to get my head around building Docker images with Google's Jib project and Jib Maven Plugin.
I don't understand how to specify the JRE version.
I understand I can customize in the plugin's config, something like:
<configuration>
<from>
<image>gcr.io/distroless/java</image>
</from>
</configuration>
but what does that mean in terms of the actual JRE version which will be used ? What if I want say specifically JRE 8u172 ?
The Jib project states this as a feature:
Reproducible - Rebuilding your container image with the same contents always generates the same image.
therefore I'm assuming there must be some way to lock down the JRE version?
Level: Advanced on Java and Maven, newbie on everything Docker.
Controllers use Java 11 by default If you are running one of the Jenkins Docker controller images that does not include a JDK version in its label, the Java runtime will switch from Java 8 to Java 11 with the upgrade. For example: Jenkins 2.306 running as jenkins/jenkins:latest uses Java 8.
Jib builds containers without using a Dockerfile or requiring a Docker installation. You can use Jib in the Jib plugins for Maven or Gradle, or you can use the Jib Java library.
Use a JRE, not a JDK When creating a Docker image, we should only assign the necessary resources to function correctly. This means that we should start by using an appropriate Java Runtime Environment (JRE) for your production image and not the complete Java Development Kit (JDK).
Jib is a set of plugins for Maven and Gradle for building optimized OCI-compliant container images for Java applications without a Docker daemon.
Availability of 8u172 depends on whether the distributor has created a build image of that version.
java building version is not managed with docker image tags with gcr.io/distroless/java
.
Currently gcr.io/distroless/java:8
, it was 8u212 as below.
https://console.cloud.google.com/gcr/images/distroless/GLOBAL/java?gcrImageListsize=30
~ $ docker run -it --rm --entrypoint java gcr.io/distroless/java:8 -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-8u212-b01-1~deb9u1-b01)
OpenJDK 64-Bit Server VM (build 25.212-b01, mixed mode)
~ $
If you want to specify to java build version, I suggest using AdroptOpenJDK.
e.g.
<configuration>
<from>
<image>adoptopenjdk/openjdk8:jdk8u172-b11</image>
</from>
</configuration>
If you can use 8u171, you can select openjdk.
<configuration>
<from>
<image>openjdk:8u171-jre</image>
</from>
</configuration>
You probably want to use a base image with java preinstalled. every docker image contains tag(s), which are like versions. if you don't specify tag like you did above, then the latest is taken and that can lead to unexpected change of java version.
For example you can use opendjk
image with java version 8u212
by using openjdk:8u212-jre-stretch
. and in OpenJDK Docker Hub you can see the list of all available tags
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