Get Started with Azul Platform Prime using Docker
Note
|
Need a different Linux distro? Go back to Azul Platform Prime Downloads. |
These instructions guide you through the Azul Platform Prime installation using Docker.
Prerequisites
Install Docker by following the Docker documentation.
Using Docker Azul Zing Builds of OpenJDK
Docker images of Azul Zing Builds of OpenJDK (Zing) are provided through Docker Hub.
CentOS, Debian, and Ubuntu based official Docker images of Zing are available in the following repositories:
OS | Image Name |
---|---|
Ubuntu |
azul/prime |
Debian |
azul/prime-debian |
CentOS |
azul/prime-centos |
Usage
The Azul Platform Prime repository supports numerous versions of OpenJDK-based Java SE JDKs. To run a container of your choice, add the Java version suffix you wish to pull. For example, to pull the image with JDK 21, run one of the following depending on the system you want it to be based on:
# Ubuntu
docker pull azul/prime:21
# Debian
docker pull azul/prime-debian:21
# CentOS
docker pull azul/prime-centos:21
Run Java apps
You can test the Docker image by running the following command in a terminal:
docker run -it --rm azul/prime:21 java -version
The command allocates a terminal and runs java
.
It prints a message similar to this:
openjdk version "21.0.6.0.101" 2025-04-29 LTS
OpenJDK Runtime Environment Zing25.04.0.0+2 (build 21.0.6.0.101+2-LTS)
Zing 64-Bit Tiered VM Zing25.04.0.0+2 (build 21.0.6.0.101-zing_25.04.0.0-b2-release-linux-aarch64, mixed mode)
If you see this message in your terminal, you’ve successfully executed java
inside a container.
The command above simply executes java
.
To run a Java application, you must provide your application classes and resources to the java
command.
You do this by mounting a local directory from the container.
As an example, let’s assume that your application files are located in a single directory.
You would normally run the app by executing java MyApp
in that directory.
Use the -v
option of docker run
to make the directory available inside the container.
The command might look like this:
docker run -it --rm \
-v ${PWD}:/usr/src/project \
-e CLASSPATH=/usr/src/project \
azul/prime:21 java MyApp
Create your own Docker Image with Zing
Creating your own Docker image with Zing is a great way to ensure your application runs consistently in different environments.
First, create a file named Dockerfile
in your application’s directory, where your application’s jar file is located. Make sure the file does not have a file extension. This file serves as the configuration for your Docker build process. Use the example file here or the example Dockerfiles in the next section to help you write your Dockerfile:
# Specify the JDK image to use from Docker Hub
FROM azul/zing:21
# Set the working directory in the container
WORKDIR /app
# Copy your Java application JAR file into the working directory
COPY My-App.jar /app
# The command to run your application
CMD ["java", "-jar", "My-App.jar"]
Once you have your Dockerfile, you can build your Docker image. Open your terminal and navigate to the directory containing your Dockerfile and jar file. Run the following command to build your Docker image:
docker build -t image-name .
When your Docker image is finished building, you should get a message like this:
[+] Building 20.9s (9/9) FINISHED
You are now finished building your Docker image. If you are using Docker Desktop, your image should already be in the list of images. To run your image, use:
docker run -d --name container-name image-name
Example Dockerfiles
Create a Container Based on CentOS Stream
# containerfile example using the Azul Zing stable release
# docker build --build-arg=ftpuser=CUSTOMERUSER --build-arg=ftppassword='CUSTOMERPASSWD' \
# -t zingtest -f zing_centos_containerfile.txt
# docker run --rm -i -t zingtest java -version
#
FROM quay.io/centos/centos:stream9
ARG ftpuser
ARG ftppassword
ARG ftpselection=jdk17
ENV FTPBASEURL=https://ftp.azul.com/releases/Zing/latest-stable/
RUN ftpfile=$(curl --user "$ftpuser:$ftppassword" --list-only --silent --location $FTPBASEURL \
| grep "${ftpselection}.*linux.$(rpm --eval '%{_arch}').rpm<" \
| sed -E 's/.*href=\"(zing.*)\".*/\1/' | sort -n | tail -1) \
&& curl -O -L --user "$ftpuser:$ftppassword" $FTPBASEURL/$ftpfile \
&& rpm --import https://repos.azul.com/azul-repo.key \
&& (rpm -K $ftpfile | grep 'digests signatures OK') \
&& dnf localinstall -y $ftpfile \
&& rm $ftpfile \
&& dnf clean all
Create a Container Using the Zing Download API
# Zing stable-release containerfile example
# docker build --build-arg=apikey=MYAPITOKEN -t zingtest -f zing_api_ubuntu_containerfile.txt
# docker run --rm -i -t zingtest java -version
FROM ubuntu:24.04
ARG apikey
ARG version=17
ARG release=stable
RUN apt update \
&& apt install -y curl gnupg dpkg-dev jq
RUN APIURL="https://api.azul.com/metadata/v1/zing/packages/?java_version=$version&os=linux&arch=$(dpkg-architecture -q DEB_HOST_GNU_CPU)&archive_type=deb&java_package_type=jdk&latest=true&crs_supported=true&build_types=$release" \
&& URL=$(curl -s -H "Authorization: Bearer $apikey" -H "accept: application/json" -X GET "$APIURL" | jq -r '.[].download_url' | head -1) \
&& curl -s -L -o /tmp/zing.deb "$URL" \
&& curl -s https://repos.azul.com/azul-repo.key | gpg --import \
&& gpg --verify /tmp/zing.deb \
&& apt install -y /tmp/zing.deb \
&& rm /tmp/zing.deb \
&& echo "export JAVA_HOME=$(dirname $(dirname $(readlink -f /etc/alternatives/java)))" >> /etc/bash.bashrc