Detailed breakdown of each instruction and how it fits as the final “container packaging” step in your Azure AKS deployment workflow.
target/app.jar into a runnable container
FROM eclipse-temurin:21-jre
WORKDIR /app
COPY target/app.jar /app/app.jar
EXPOSE 9087
ENTRYPOINT ["java","-jar","/app/app.jar"]
In an AKS workflow, everything before this produces the application artifact (app.jar).
This Dockerfile is the final step that turns that artifact into a deployable container image.
mvn clean install produces target/app.jar.
COPY.docker build -t aks-demo-ui:1.0 .
aks-demo-ui:1.0 on your machine (Docker Desktop).
docker run --rm -p 9087:9087 --name aks-demo-ui aks-demo-ui:1.0
/actuator/health, the image is ready to push and deploy.
Selects the container base image. This one provides a production-grade Java 21 runtime (JRE), which is enough to run your Spring Boot executable jar.
java -jar.
Sets the default working directory inside the image. All following file operations and commands
use /app unless explicitly overridden.
Copies the built jar from your local build context (your project directory) into the container filesystem. This line is the “hand-off” between Maven output and the runnable container image.
<finalName>app</finalName>,
producing target/app.jar.
target/app.jar doesn’t exist, the Docker build fails at this step.
Always run Maven first.
Declares that the containerized application listens on port 9087.
This is primarily documentation/metadata for humans and tooling.
EXPOSE does not publish the port by itself.
Publishing happens when you run:
docker run -p hostPort:containerPort,
and in Kubernetes via containerPort + Service/Ingress.
Defines the default process executed when the container starts. Here, the container runs Java in “exec form” (JSON array), which is the recommended form for predictable signal handling and argument parsing.
java -jar /app/app.jar. Logs go to stdout/stderr,
which is what Kubernetes expects for centralized log collection.