Docker File for building image

Hello-

I want to build a docker image for spring boot with tomcat enabled and JRE 21. I would run it later in Azure DevOps pipeline Agent based on RHEL 8.

I am creating the docker file but confused with the base image. i have created this docker file. Can anyone verify if this docker file i am missing anything ?

</>

Use Red Hat Universal Base Image (UBI) 8 as the base image

FROM registry.access.redhat.com/ubi8/ubi

Set environment variables

ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk
ENV PATH=$PATH:$JAVA_HOME/bin

Install OpenJDK 11 (replace with JDK 21 if available)

RUN yum install -y java-11-openjdk-devel &&
yum clean all

Copy the Spring Boot application JAR file into the container

COPY target/your-application.jar /app/your-application.jar

Expose port 8080 for Tomcat

EXPOSE 8080

Command to run the Spring Boot application

CMD [“java”, “-jar”, “/app/your-application.jar”]

</>
################################

if i have JDK 21 on my self hosted agent VM, do i need below in docker file

Install OpenJDK 11 (replace with JDK 21 if available)

RUN yum install -y java-11-openjdk-devel &&
yum clean all


Please, format your post according to the following guide: How to format your forum posts
In short: please, use </> button to share codes, terminal outputs, error messages or anything that can contain special characters which would be interpreted by the MarkDown filter. Use the preview feature to make sure your text is formatted as you would expect it and check your post after you have sent it so you can still fix it.

Example code block:

```
echo "I am a code."
echo "An athletic one, and I wanna run."
```