4.1. Understanding Dockerfile Commands
This is an optional chapter designed to help you deeply understand what each line in the Dockerfile accomplishes.
Docker Architecture Overview
architecture-beta
group container(cloud)[Docker Container]
service jre(server)[Java 17 JRE] in container
service app(disk)[/app directory] in container
service jar(database)[app.jar] in container
jre:R --> L:jar
1. Base Image
FROM eclipse-temurin:17-jre
This tells Docker to start with a lightweight Alpine Linux distribution that comes pre-installed with the Java 17 Runtime Environment.
2. Working Directory
WORKDIR /app
This creates a folder named /app inside the Docker image and sets it as the default directory for all subsequent commands.
3. Copying the Artifact
COPY target/bigkart-0.0.1-SNAPSHOT.jar app.jar
This takes the JAR file from your local target folder and copies it into the /app folder inside the image, renaming it to simply app.jar.
4. Exposing Ports
EXPOSE 8080
Since the Docker Image is essentially a virtual environment, we must explicitly expose port 8080 so that external traffic can reach our Spring Boot application.
5. Execution Command
ENTRYPOINT ["java", "-jar", "app.jar"]
This defines the default command that runs when the container starts up. It executes the Spring Boot application!