jdk 21
Runtime · Language runtime · standard · v21
Hardened OpenJDK with javac. LTS lines 17/21/25.
Version line
The latest line lives at the base page; older lines have their own page so you can pin and verify exactly that version.
Use it as a base image
Reference it in the FROM line of your Dockerfile. Nonroot, read-only
root filesystem, built for amd64 and arm64.
FROM ghcr.io/quenchworks/images/jdk:21 Or pull it directly
docker pull ghcr.io/quenchworks/images/jdk:21 - Version line
- 21
- Latest line
- 17, 21, 25
- Architectures
- amd64, arm64
- Runs as
- nonroot (uid 1001)
- Root filesystem
- read-only
- License
- GPL-2.0-with-classpath-exception
Verify the supply chain
This image is cosign-signed and carries an SPDX SBOM and a SLSA build-provenance attestation on the same digest. Check all three before you build on it:
# 1. signature — built and signed by QuenchWorks CI
cosign verify ghcr.io/quenchworks/images/jdk:21 \
--certificate-identity-regexp 'https://github.com/quenchworks/.+' \
--certificate-oidc-issuer https://token.actions.githubusercontent.com
# 2. SLSA build provenance — which workflow built it, from what
gh attestation verify oci://ghcr.io/quenchworks/images/jdk:21 --owner quenchworks
# 3. SPDX SBOM — the package inventory
gh attestation verify oci://ghcr.io/quenchworks/images/jdk:21 --owner quenchworks \
--predicate-type https://spdx.dev/Document See the SBOM & provenance guide for reading the SBOM and using these checks in CI.
Best-practice Dockerfile for 21
Compile and package the jar with the full JDK in the build stage, then run it on the slim jre base. The compiler and build outputs stay behind; only the jar ships.
# Build stage: compile and package the jar with the full JDK.FROM ghcr.io/quenchworks/images/jdk:21 AS buildUSER rootWORKDIR /app
COPY . .RUN ["javac", "-d", "/app/out", "@sources.txt"]RUN ["jar", "--create", "--file", "/app/app.jar", "--main-class", "App", "-C", "/app/out", "."]
# Runtime stage: run the jar on the slim JRE base, nonroot.FROM ghcr.io/quenchworks/images/jre:21 AS runtimeWORKDIR /appCOPY --from=build /app/app.jar /app/app.jarUSER 1001EXPOSE 8080ENTRYPOINT ["java", "-Djava.io.tmpdir=/tmp", "-jar", "/app/app.jar"]This Dockerfile is pinned to the 21 line. For the line-by-line walkthrough and ecosystem variants (npm/Yarn, pip/uv/Poetry, Maven/Gradle), see the Build a Java app guide.
Upstream project: https://openjdk.org