Visit Azul.com Support

Run Azul Zulu in a Docker Container

Table of Contents
Need help?
Schedule a consultation with an Azul performance expert.
Contact Us

This section shows how to run Azul Zulu inside a Docker container.

Prerequisites

Install Docker by following the Docker documentation.

Azul Docker images

Azul provides Docker images with Azul Zulu Builds of OpenJDK pre-installed on one of the following operating systems:

OS Image Name

Ubuntu

azul/zulu-openjdk

Debian

azul/zulu-openjdk-debian

Alpine Linux

azul/zulu-openjdk-alpine

CentOS

azul/zulu-openjdk-centos

To pull a specific image, use the corresponding image name in the docker pull command. For example, to pull the Alpine Linux image with Azul Zulu JDK 21, run:

 
docker pull azul/zulu-openjdk-alpine:21

Run Java apps

You can test the Docker image by running the following command in a terminal:

 
docker run -it --rm azul/zulu-openjdk:21 java -version

The command allocates a terminal and runs java. It prints a message similar to this:

 
openjdk version "21.0.4" 2024-07-16 LTS OpenJDK Runtime Environment Zulu21.36+17-CA (build 21.0.4+7-LTS) OpenJDK 64-Bit Server VM Zulu21.36+17-CA (build 21.0.4+7-LTS, mixed mode, sharing)

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/zulu-openjdk:11 java MyApp