Creating a Container Image with External Java and Python
This procedure describes how to create a Docker container image that contains your own Java and Python instead of the default BMC-provided image that already contains Java version 21 (OpenJDK) and Python.
You need to create your image from another BMC-provided image that does not contain Java or Python. This image has the 9.22.100-k8s or 9.22.100-k8s-mft 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 and Python 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.22.100-k8s
ENV BMC_INST_JAVA_HOME=<path to your installed JDK>
RUN <JDK installation commands>
RUN <Python installation commands>
RUN ./update_java_home.shTo create a custom image on top of an MFT base image, use 9.22.100-k8s-mft instead of 9.22.100-k8s.
Dockerfile with Amazon Corretto JDK:
CopyFROM controlm/agent:9.22.100-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 PYTHON_VERSION=3.12
ENV PYTHON_LIB=python${PYTHON_VERSION//./}
RUN set -ex \
&& echo "Install Python lib: ${PYTHON_LIB}" \
&& microdnf install -y ${PYTHON_LIB} \
&& microdnf clean all \
# Configure Python environment
&& ln -s /usr/bin/python${PYTHON_VERSION} /usr/bin/python \
&& python${PYTHON_VERSION} -m ensurepip \
&& ln -s /usr/bin/pip3 /usr/bin/pip \
&& echo "Python versions:" \
&& python --version \
&& pip3 --version
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
