Image Overview: jre

Overview: jre Chainguard Image

WARNING

This image will switch from including a full complement of JDK binaries to a minimally required set in a forthcoming release. The work is being tracked in this GitHub issue.

If you rely on any binaries or libraries that are included in this image beyond the core JRE runtime, consider switching to the JDK Image.

Minimalist Wolfi-based Java JRE image using OpenJDK. Used for running Java applications.

Download this Image

The image is available on cgr.dev:

docker pull cgr.dev/chainguard/jre:latest

Java Application Example

This section outlines how you can build a Java application with the Chainguard JRE Image.

Start by creating a sample Java class named HelloWolfi.java:

cat >HelloWolfi.java <<EOL
class HelloWolfi
{
    public static void main(String args[])
    {
        System.out.println("Hello Wolfi users!");
    }
}
EOL

Then create a multistage Dockerfile, adding the Java class you just created:

cat >Dockerfile <<EOL
FROM cgr.dev/chainguard/jdk

COPY HelloWolfi.java /home/build/
RUN javac HelloWolfi.java

FROM cgr.dev/chainguard/jre

COPY --from=0 /home/build/HelloWolfi.class /app/
CMD ["HelloWolfi"]
EOL

Following that, you can build the image:

docker build -t my-java-app .

Note that this example tags the image with my-java-app. You can now run the image by referencing this tag, as in the following command:

docker run my-java-app
Hello Wolfi users!

Last updated: 2024-03-01 12:14