Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 57 additions & 89 deletions oci/jre/documentation.yaml
Original file line number Diff line number Diff line change
@@ -1,61 +1,22 @@
version: 1

version: 2
application: jre
is_chiselled: true
description: |
This image packs the Java Runtime Environment, coming
from the [OpenJDK project](https://www.openjdk.org/), a free and open
OpenJDK is the official reference implementation of Java Platform,
Standard Edition (Java SE), since version 7. This image packs the Java
Runtime Environment, coming from the
[OpenJDK project](https://www.openjdk.org/), a free and open
source implementation of the Java Platform, Standard Edition (Java SE).
OpenJDK is the official reference implementation of Java SE since
version 7. [Read more](https://openjdk.org/).

Java is a registered trademark of Oracle and/or its affiliates.

## About Chiselled Ubuntu

This image does not include bash nor a package manager nor the OpenJDK.
Its purpose is to serve as a runtime, final-stage base image for
compatible Java applications.

Read more about chiselled Ubuntu for OpenJDK JRE, a new class of OCI images,
on [the Ubuntu blog](https://ubuntu.com/blog/combining-distroless-and-ubuntu-chiselled-containers).
And remember, the best base image is FROM scratch: so you could also
[easily craft your own chiselled Ubuntu base](https://ubuntu.com/blog/craft-custom-chiselled-ubuntu-distroless)
for your app specific needs.

Please note that the Ubuntu 22.04 JRE images are Dockerfile-base
images, whereas from Ubuntu 24.04 onward the images
Comment thread
asanvaq marked this conversation as resolved.
are now rocks. As such the entrypoint is now Pebble. Read more on the
[Rockcraft docs](https://canonical-rockcraft.readthedocs-hosted.com/en/latest/explanation/rocks/).

Ubuntu 22.04 JRE images have `java` as the entrypoint.

```bash
$ docker run --rm ubuntu/jre:17_edge
Usage: java [options] <mainclass> [args...]
```

Ubuntu 24.04 JRE images have `pebble enter`
as the entrypoint. You can access the `java` with the following
command:

```bash
$ docker run --rm ubuntu/jre:21_edge exec java
Usage: java [options] <mainclass> [args...]
...
```
Note: The official OpenJDK 25 JRE image includes java.compiler and
jdk.compiler modules. Therefore, the chiseled image can run .java files.
website: https://openjdk.org
issues: https://github.com/canonical/jre-rock/issues
source-code: https://github.com/canonical/jdk-rock

docker:
parameters:
- --rm
access: |
For Ubuntu 24.04 JRE

```bash
docker run --rm --name jre-container -e TZ=UTC ubuntu/jre:21-24.04_edge exec java
```

run_cmd: exec java
parameters: >-
--rm
run_conclusion: |
The container logs will simply show the OpenJRE help message.
This is because the container expects a compiled Java application to be given.

Expand All @@ -72,29 +33,10 @@ docker:
}
}
```

You can build and package the above Hello World application with
chiselled Ubuntu 22.04 JRE 8 and 17 using the following example
chiselled Ubuntu 24.04 using the following example
Dockerfile.

```docker
FROM ubuntu:22.04 AS builder
RUN apt-get update && apt-get install -y openjdk-8-jdk
WORKDIR /app
ADD HelloWorld.java .

RUN javac -source 8 -target 8 HelloWorld.java -d .

FROM ubuntu/jre:8-22.04_edge

WORKDIR /
COPY --from=builder /app/HelloWorld.class .

CMD [ "HelloWorld" ]
```

For Ubuntu 24.04 please use

```docker
FROM ubuntu:24.04 AS builder
RUN apt-get update && apt-get install -y openjdk-8-jdk
Expand All @@ -110,26 +52,52 @@ docker:
CMD [ "exec", "java", "-cp", "/", "HelloWorld" ]
```

legacy:
parameters: >-
--rm
run_conclusion: |
The Ubuntu 22.04 JRE images are Dockerfile-based images.

You can build and package the above Hello World application with
chiselled Ubuntu 22.04 JRE 8 and 17 using the following example
Dockerfile.

```docker
FROM ubuntu:22.04 AS builder
RUN apt-get update && apt-get install -y openjdk-8-jdk
WORKDIR /app
ADD HelloWorld.java .

RUN javac -source 8 -target 8 HelloWorld.java -d .

FROM ubuntu/jre:8-22.04_edge

WORKDIR /
COPY --from=builder /app/HelloWorld.class .

CMD [ "HelloWorld" ]
java [options] <mainclass> [args...]
...
```

config:
TZ:
type: env
description: Configures the timezone value for Java process execution.
'`-v <host-path>:/app`':
type: mount
description: Configure with a host mount to provide compiled classes or application files.
'`exec java <args>`':
type: app
description: Execute with Java command arguments or classpath options.
'`--rm`':
type: other
description: Run with automatic container cleanup after exit.

override_tracks:
# Tracks release from legacy repo
#(https://github.com/rockcrafters/chiselled-jre/)
# (https://github.com/rockcrafters/chiselled-jre/)
8-22.04:
end-of-life: "2027-06-01T00:00:00Z"
17-22.04:
end-of-life: "2027-06-01T00:00:00Z"

debug:
text: |
### Debugging

To debug the container:

```bash
docker logs -f openjdk-jre-container
```

For Ubuntu 24.04 JRE, to inspect application logs:

```bash
docker exec openjdk-jre-container pebble logs
```
Loading