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
Talk about OpenJDK?
Discuss with the community on the Foojay Forum.
Go to Forum

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 15, run:

 
docker pull azul/zulu-openjdk-alpine:15

Run Java apps

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

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

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

 
openjdk version "15.0.2" 2021-01-19 OpenJDK Runtime Environment Zulu15.29+15-CA (build 15.0.2+7) OpenJDK 64-Bit Server VM Zulu15.29+15-CA (build 15.0.2+7, 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