Sign inSign up

Microsoft Build of OpenJDK

Verified Publisher

openjdk/jdk

By Microsoft

Updated over 2 years ago

Microsoft Build of OpenJDK for Java

0

microsoft/openjdk-jdk repository overview

About

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 OSOpenJDK 25OpenJDK 21OpenJDK 17OpenJDK 11OpenJDK 8 (1)
Azure Linux 3.0 (2)25-azurelinux21-azurelinux17-azurelinux11-azurelinux8-azurelinux
Ubuntu 22.0425-ubuntu21-ubuntu17-ubuntu11-ubuntuN/A
Azure Linux 3.0 Distroless25-distroless21-distroless17-distroless11-distroless8-distroless
  • Note (1): Images for OpenJDK 8 ship with binaries of Eclipse Temurin, from the Eclipse Adoptium project.
  • Note (2): Legacy container image tags such as 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 End of Life images

Legacy images based on CBL Mariner 2.0 and CBL Mariner 1.0, have reached End of Life and should not be used.

Base OSOpenJDK 21OpenJDK 17OpenJDK 11OpenJDK 8 (1)
CBL Mariner 2.021-mariner-cm217-mariner-cm211-mariner-cm28-mariner-cm2
CBL Mariner 1.0N/A17-mariner-cm111-mariner-cm1N/A
  • Note (1): Images for OpenJDK 8 ship with binaries of Eclipse Temurin, from the Eclipse Adoptium project.

Architectures

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.

How to use these images

# 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"]

Distroless Images

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"]

Use a different Base OS image

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.

Create a custom Java runtime

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

Stay on older minor versions

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.

Full Tag Listing

Visit the MCR for latest tag list.

Configuration

None.

Support

Support for the Microsoft Build of OpenJDK

Feedback

Send us your feedback on our docker images to microsoft/openjdk-docker

License

Further Reading

Tag Summary

No tags have been pushed to this repository yet.