Dockerize Spring MVC Application — Microservices
Spring mvc is not being used in industry. They have moved to the spring boot. But in sometimes, projects that had been started long time back are still using Spring mvc. I also working with such kind of project. So they needed to dockerize their existing application that are based on spring mvc. Let’s go to the tutorial now.
First we need to pull the latest tomcat image from docker repository using following command.
docker pull tomcat:latest
Next you can create docker file and configure tomcat image according to your needs. Now we’ll call configured tomcat images as a “base_tomcat:1.0”
Now we’ll go to our spring mvc project. Here we need to add spotify docker-maven-plugin inside in pom.xml file.
Documentation : https://github.com/spotify/docker-maven-plugin
you can see that this plugin will execute in install phase. every time you do maven install, docker image of your project will be created. What is really happening here is that we are creating tomcat image having put the project war file inside the webapps directory of tomcat image.
Now you have successfully dockerized your project. Now let’s run this image.
Now you will be able to access your application through localhost:8080/….
Hope you will be able to understand the concept of this.
If you like this post, you can read more articles on my personal blog devpubba.com.