• +94712452807
  • pubudu2013101@gmail.com
  • No 39, 2nd Lane, Dikhenapura, Horana
Docker
Dockerize Spring MVC Application — Microservices

Dockerize Spring MVC Application — Microservices

Spring MVC is not being used in the industry. They have moved to the spring boot. But sometimes, projects that had been started a 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 is 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 a 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 the install phase. every time you do maven install, the docker image of your project will be created. What is really happening here is that we are creating a tomcat image having put the project war file inside the web apps 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.

Leave a Reply

Your email address will not be published.