Dockerizing Our Application
Generate a .jar file
- Next, let’s generate the .jar file by executing the command ./mvnw clean package in your IntelliJ terminal. This command compiles the project, runs any necessary tests, and packages the application into a .jar file.
- Once the process is complete, navigate to the target folder within your project directory. You’ll find the generated spring-0.0.1-SNAPSHOT.jar file there.
Now create a new jar file using maven builder.
$ ./mvnw clean package
The above command will build our docker image. Below image refers to generate the jar file by executing the above command. Refer the second image the build was success and jar file created.
How To Dockerize A Spring Boot Application With Maven ?
Docker is an open-source containerization tool used for building, running, and managing applications in an isolated environment. A container is isolated from another and bundles its software, libraries, and configuration files. In this article, to dockerize a Spring Boot application for deployment purposes, we will learn how to create a spring boot app, and how to create a docker image for the spring boot app and we will run it on the docker container.
Prerequisites: Before continuing any further, please ensure that node and docker are installed on your machine. If required, visit the Java Installation Guide or the Docker Installation Guide.
Contact Us