
OpenJDK
An image used to run and build Java applications.
What is OpenJDK?
The openjdk image provides a containerized distribution of the Open Java Development Kit (OpenJDK), used to run and build Java applications. OpenJDK is the reference implementation of the Java Platform, and this image includes the Java runtime (JRE), the compiler (javac), and core Java libraries.
This image is used to build, test, and run Java applications inside containers. It supports multiple Java versions (e.g. 8, 11, 17, 21) and is widely adopted in CI pipelines, production microservices, and legacy modernization efforts.
The openjdk image is maintained by the Docker Official Images team and is suitable for teams that need a reliable, vendor-neutral JDK in containerized environments.
How to use this image
The image can be used as a runtime for Java applications or as a build environment for compiling and packaging Java code.
Run a Java application:
<code>docker run --rm -v $(pwd):/app -w /app openjdk:17 java -jar myapp.jar</code>
Compile Java code inside the container:
<code>docker run --rm -v $(pwd):/src -w /src openjdk:17 javac HelloWorld.javadocker run --rm -v $(pwd):/src -w /src openjdk:17 java HelloWorld</code>
Use as a base image in a Dockerfile:
<code>EditFROM openjdk:17-jdk-slimCOPY myapp.jar /app/myapp.jarENTRYPOINT ["java", "-jar", "/app/myapp.jar"]</code>
Logging and behavior:
Java logs are printed to stdout
by default. Behavior is defined by the application being executed within the JVM.
Image variants
Published under openjdk
, this image includes a wide range of variants based on Java version, package type (JDK vs JRE), and base OS.
openjdk:<version>
Default full JDK for a given Java version (e.g. openjdk:17
, openjdk:21
) .Use for general development or build environments.
openjdk:<version>-slim
A slimmer Debian-based variant with reduced dependencies.Ideal for reducing image size while retaining full functionality.•
openjdk:<version>-alpine
(deprecated or unavailable in newer versions)Formerly based on Alpine Linux; deprecated due to JVM compatibility issues.•
openjdk:<version>-jdk / -jre
JDK includes compiler (javac
); JRE includes only the runtime.
Use -jre
when running apps and not compiling code.Always match the Java version to your application’s requirements (e.g. 8 for legacy apps, 17+ for newer services). The -slim
variants are recommended for most production images.