openjdk/jdk
Microsoft Build of OpenJDK for Java
These Microsoft Build of OpenJDK container images and corresponding Dockerfiles are designed to be used for any Java applications or Java application components.
We currently provide Linux-based container images for Ubuntu and Microsoft Azure Linux. The images are published in the Microsoft Container Registry located at mcr.microsoft.com/openjdk/jdk. You can also visit mcr.microsoft.com/en-us/product/openjdk/jdk/tags for the latest list of available tags.
To pull the latest image for a specific tag, use the following command:
docker pull mcr.microsoft.com/openjdk/jdk:<tag>
The following table shows the tag to use for your Linux distribution and JDK version.
| Base OS | OpenJDK 25 | OpenJDK 21 | OpenJDK 17 | OpenJDK 11 | OpenJDK 8 (1) |
|---|---|---|---|---|---|
| Azure Linux 3.0 (2) | 25-azurelinux | 21-azurelinux | 17-azurelinux | 11-azurelinux | 8-azurelinux |
| Ubuntu 22.04 | 25-ubuntu | 21-ubuntu | 17-ubuntu | 11-ubuntu | N/A |
| Azure Linux 3.0 Distroless | 25-distroless | 21-distroless | 17-distroless | 11-distroless | 8-distroless |
25-mariner, 21-mariner, 17-mariner, 11-mariner, and 8-mariner that were previously built with Mariner 2.0, are now mirroring the tags -azurelinux, following a rebrand and upgrade of this Linux distribution. If necessary, users can downgrade to CBL Mariner 2.0 with the tags -mariner-cm2.Legacy images based on CBL Mariner 2.0 and CBL Mariner 1.0, have reached End of Life and should not be used.
| Base OS | OpenJDK 21 | OpenJDK 17 | OpenJDK 11 | OpenJDK 8 (1) |
|---|---|---|---|---|
| CBL Mariner 2.0 | 21-mariner-cm2 | 17-mariner-cm2 | 11-mariner-cm2 | 8-mariner-cm2 |
| CBL Mariner 1.0 | N/A | 17-mariner-cm1 | 11-mariner-cm1 | N/A |
The images above are offered for both amd64 and arm64 architectures. Your container runtime shall pull the right image based on your environment. To force a pull of an image for a specific architecture, use the following:
$ docker pull --platform=linux/arm64 mcr.microsoft.com/openjdk/jdk:17-azurelinux
To force an architecture inside a Dockerfile, you may use the following:
FROM --platform=linux/arm64 mcr.microsoft.com/openjdk/jdk:17-azurelinux AS build
# ...
For more information on building multi-platform container images, check the documentation of your container runtime. For example, Docker and Podman.
# Example using MS Build of OpenJDK image directly
FROM mcr.microsoft.com/openjdk/jdk:17-ubuntu
# Continue with your application deployment
RUN mkdir /opt/app
COPY japp.jar /opt/app
CMD ["java", "-jar", "/opt/app/japp.jar"]
The distroless images are based on the Azure Linux 3.0 distribution by Microsoft. They require a different approach to deploying an application. Because the distroless images do not contain a complete Linux distribution, there is no shell, for example.
The ENTRYPOINT of these images is already configured pointing to the java command. Consuming Dockerfiles must use the CMD instruction to complete the command-line arguments of the JVM launcher process.
Create a Dockerfile with the following contents:
FROM mcr.microsoft.com/openjdk/jdk:17-distroless
COPY app.jar /app.jar
CMD ["-Xmx256m", "-jar", "/app.jar"]
If you prefer an OS base image distribution that we don't provide an image for, you can copy the JDK using the COPY --from instruction in a Dockerfile, similar to the following example:
# Example using MS Build of OpenJDK image with a different base image
FROM debian:buster-slim
ENV JAVA_HOME /usr/lib/jvm/msopenjdk-17-amd64
ENV PATH "${JAVA_HOME}/bin:${PATH}"
COPY --from=mcr.microsoft.com/openjdk/jdk:17-ubuntu $JAVA_HOME $JAVA_HOME
# Continue with your application deployment
RUN mkdir /opt/app
COPY japp.jar /opt/app
CMD ["java", "-jar", "/opt/app/japp.jar"]
You can also install the JDK using either yum or apt-get, or simply extracting a tar.gz file and configuring JAVA_HOME accordingly. Read more.
To create a custom Java runtime image, use a Dockerfile similar to the following example:
# Example of custom Java runtime using jlink in a multi-stage container build
FROM mcr.microsoft.com/openjdk/jdk:17-ubuntu as runtime-build
# Create a custom Java runtime
RUN $JAVA_HOME/bin/jlink \
--add-modules java.base \
--strip-debug \
--no-man-pages \
--no-header-files \
--compress=2 \
--output /javaruntime
# Define your base image. You may use any base OS and version of your choice.
FROM debian:buster-slim
ENV JAVA_HOME /usr/lib/jvm/msopenjdk-17-amd64
ENV PATH "${JAVA_HOME}/bin:${PATH}"
COPY --from=runtime-build /javaruntime $JAVA_HOME
# Continue with your application deployment
RUN mkdir /opt/app
COPY japp.jar /opt/app
CMD ["java", "-jar", "/opt/app/japp.jar"]
For more information on creating custom Java runtimes, see Java Runtimes with jlink
Microsoft Build of OpenJDK container images are only available under the tags listed previously. We don't publish tags for minor versions, and the major version tags always have the latest minor version to ensure that developers will always have the latest update for any given major version.
These base images use the underlying package manager mechanism of the Linux distributions to install the JDK package. Therefore, to stay on a particular version, you'll need to use tools such as apt-get or yum to install the specific minor version of the JDK.
In your Dockerfile, you can code this with the following examples:
For Ubuntu:
FROM mcr.microsoft.com/openjdk/jdk:11-ubuntu
...
RUN apt-get update && \
apt-get install -y --allow-downgrades msopenjdk-11=11.0.26-1
...
For Azure Linux:
FROM mcr.microsoft.com/openjdk/jdk:11-azurelinux
...
RUN tdnf update -y && \
tdnf install -y --nogpgcheck msopenjdk-11-11.0.26-1
...
For more information and details on this topic, please visit the Microsoft Build of OpenJDK documentation.
Visit the MCR for latest tag list.
None.
Support for the Microsoft Build of OpenJDK
Send us your feedback on our docker images to microsoft/openjdk-docker
No tags have been pushed to this repository yet.