Creating a Container Image with External Java
This procedure describes how to create a Docker container image that contains your own Java instead of the default BMC-provided image that already contains Java version 17 (OpenJDK).
You need to create your image from another BMC-provided image that does not contain Java. This image has the 9.21.315-k8s tag and is stored in the controlm/agent repository in the Docker Hub.
Perform this procedure only if you want the container to use Java that you provide.
Skip this task if you use the default, BMC-provided Java.
BMC-provided images are based on AlmaLinux Minimal, which includes a microdnf package manager.
Before You Begin
Ensure that the Linux x86_64 Java package is of a supported version and vendor, as listed in Control-M Compatibility with External Java Vendors.
BMC recommends that you use a headless variant of Java, whenever available, to reduce the image footprint and save space.
Begin
-
Create a Dockerfile with the following content:
CopyFROM controlm/agent:9.21.315-k8s
ENV BMC_INST_JAVA_HOME=<path to your installed JDK>
RUN <JDK installation commands>
RUN ./update_java_home.shDockerfile with Amazon Corretto JDK:
CopyFROM controlm/agent:9.21.315-k8s
USER root
RUN echo "Install Amazon Corretto JDK" \
&& rpm --import https://yum.corretto.aws/corretto.key \
&& curl -L -o /etc/yum.repos.d/corretto.repo https://yum.corretto.aws/corretto.repo \
&& microdnf install -y java-21-amazon-corretto-devel \
&& microdnf clean all \
&& java -version
ENV BMC_INST_JAVA_HOME=/etc/alternatives/java_sdk
ARG USERNAME=controlm
USER $USERNAME
RUN ./update_java_home.sh -
Build an image based on the Dockerfile that you created by running the following command:
docker build . --tag <image name>
The image name includes the name of the repository where you want to upload the created image.
docker build . --tag private_repo/agent-with-amazon-corretto-java
-
Push the image to your private repository by running the following command:
docker push <image name>
The image name includes the name of the repository where you want to upload the image.
docker push private_repo/agent-with-amazon-corretto-java
