# Docker File for building image

**URL:** <https://forums.docker.com/t/docker-file-for-building-image/141231>\
**Category:** Image Builds\
**Tags:** docker, build, docker-compose\
**Created:** [May 4, 2024, 1:33pm UTC](https://forums.docker.com/t/docker-file-for-building-image/141231 "2024-05-04T13:33:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![niren4ever](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/niren4ever/32/47500_2.png) [@niren4ever](https://forums.docker.com/u/niren4ever)\
**Post date:** [May 4, 2024, 1:33pm UTC](https://forums.docker.com/t/docker-file-for-building-image/141231/1 "2024-05-04T13:33:52Z")

</div>

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](http://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

---

<div class="post-metadata">

**Author:** ![meyay](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/meyay/32/34000_2.png) [@meyay](https://forums.docker.com/u/meyay)\
**Post date:** [May 4, 2024, 1:45pm UTC](https://forums.docker.com/t/docker-file-for-building-image/141231/2 "2024-05-04T13:45:20Z")

</div>

* * *

Please, format your post according to the following guide: [How to format your forum posts](https://forums.docker.com/t/how-to-format-your-forum-posts/127295)  
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:

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

````

* * *
