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 21 (OpenJDK).

You need to create your image from another BMC-provided image that does not contain Java. This image has the 9.21.300-k8s tag and is stored in the controlm/helix-agent repository in the Docker Hub.

Note

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 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

  1. Create a Dockerfile with the following content:

    FROM controlm/helix-agent:9.21.300-k8s
    ENV BMC_INST_JAVA_HOME=<path to your installed JDK>
    RUN <JDK installation commands>
    RUN ./update_java_home.sh 
    Example

    Dockerfile with Amazon Corretto JDK:

    FROM controlm/helix-agent:9.21.300-k8s
    ENV BMC_INST_JAVA_HOME=/etc/alternatives/java_sdk
    RUN echo "Install Amazon Corretto JDK" \
       && sudo rpm --import https://yum.corretto.aws/corretto.key \
       && sudo curl -L -o /etc/yum.repos.d/corretto.repo https://yum.corretto.aws/corretto.repo \
       && sudo microdnf install -y java-21-amazon-corretto-devel \
       && sudo microdnf clean all \
       && java -version
    RUN ./update_java_home.sh
  2. 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.

    Example

    docker build . --tag private_repo/agent-with-amazon-corretto-java

  3. 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.

    Example

    docker push private_repo/agent-with-amazon-corretto-java

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*