Running Azul Zulu CA in a Docker Container
Community Availability (CA) distributions are Azul Zulu Builds of OpenJDK that are free to download and use.
Use the following instructions to install Azul Zulu CA in a container.
Prerequisites
Install Docker by following the Docker documentation.
Creating a Docker Image with Zulu CA
Docker images with CA distributions are available from Docker Hub, based on the following operating systems:
OS | Image Name |
---|---|
Ubuntu |
|
Debian |
|
Alpine Linux |
|
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
You can check the available image tags on Docker Image Tags.
Run Java Apps With Zulu CA in Docker
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