Difficulty: beginner
Estimated Time: 5 minutes

Learn how to run a Spring Boot application within a Docker image.

In this scenario, you will first clone a sample Spring Boot application (https://github.com/f-lopes/spring-boot-example).

  1. Package a Spring Boot jar using Maven Docker image
  2. Create a Docker image
  3. Build it
  4. Run it

Congratulations, you have completed the 'Dockerize Spring Boot scenario'!

Don’t stop now! The next scenario will only take about 10 minutes to complete.

Dockerize Spring Boot

Step 1 of 4

Step 1 - Package a Spring Boot application using Docker

Packaging a Spring Boot application using Docker

Run ls -la to see the sample application (https://github.com/f-lopes/spring-boot-example).

Package the application using the Maven Docker image

Execute docker run --rm --name my-maven-project -v "$(pwd)":/usr/src/mymaven -w /usr/src/mymaven -v "/.m2":/root/.m2 maven:3.3.9-jdk-8-alpine mvn clean package to build a Spring Boot jar.

Place the generated jar into an assets/ folder: mkdir assets && mv target/spring-boot-example-0.0.1-SNAPSHOT.jar assets/