0% found this document useful (0 votes)
2 views6 pages

How to Dockerize a Spring Boot App_

This document is a cheat sheet for using Docker with Spring Boot applications. It outlines the steps to dockerize a Spring Boot app, including creating a Dockerfile, installing Docker Desktop, building the Docker image, and running the container. The provided Dockerfile specifies the use of a lightweight Java 17 image and sets up the working directory and entry point for the application.

Uploaded by

Bhuwan Chaudhary
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views6 pages

How to Dockerize a Spring Boot App_

This document is a cheat sheet for using Docker with Spring Boot applications. It outlines the steps to dockerize a Spring Boot app, including creating a Dockerfile, installing Docker Desktop, building the Docker image, and running the container. The provided Dockerfile specifies the use of a lightweight Java 17 image and sets up the working directory and entry point for the application.

Uploaded by

Bhuwan Chaudhary
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Docker with Spring Boot cheat

Sheet.

what is Docker?
How to dockerize a spring boot app?
1. Create a Dockerfile at the root level of your Project and below commands into it.
Dockerfile content :
FROM openjdk:17-jdk-slim: Uses a lightweight Java 17 image.

WORKDIR /app: Sets /app as the working directory inside the container.

COPY target/my-spring-app.jar app.jar: Copies your built app into the container.

ENTRYPOINT: Specifies the command to run your app.

2. Install Docker Desktop on your machine.

3. Build the Docker Image:


docker build -t my-spring-app .
once this command execution is successful, an image will be created which can be viewed in
the Docker Desktop

4. Run the Container:

docker run -p 8080:8080 my-spring-app

This command will run the container and will start your application.
You can also find the containers running in Docker Desktop.

You might also like