top of page

How To Dockerize Spring Boot Application

  • Writer: Anand Nerurkar
    Anand Nerurkar
  • Jul 14, 2022
  • 1 min read

How To Dockerize Sample Spring Boot Application-Microservices


Prerequisite

· JDK 11

· DockerHub account and repository

· Docker installed and running

· User must be login to Docker Desktop

· sample microservice – department-service


1. Create a Docker file for the application as below and save it as Dockerfile

--------------------Dockerfile--------------------------------------------

FROM openjdk:11

ARG JAR_FILE=target/*.jar

COPY ${JAR_FILE} department-service.jar

ENTRYPOINT ["java","-jar","/department-service.jar"]

EXPOSE 9001


2. Edit pom.xml file and make entry for spotify docker plugin to build image and push


<plugin>

<groupId>com.spotify</groupId>

<artifactId>dockerfile-maven-plugin</artifactId>

<version>1.4.13</version>

<executions>

<execution>

<id>default</id>

<goals>

<goal>build</goal>

<goal>push</goal>

</goals>

</execution>

</executions>

<configuration>

<repository>anandn76/${project.name}</repository>

<tag>${project.version}</tag>

<useMavenSettingsForAuth>true</useMavenSettingsForAuth>

</configuration>

<dependencies>

<!-- To make this work on JDK 9+ -->

<dependency>

<groupId>javax.activation</groupId>

<artifactId>javax.activation-api</artifactId>

<version>1.2.0</version>

</dependency>

</dependencies>

</plugin>




Yellow block represent docker goals such as build and push


Green part represent your docker hub repository


For below block we need to make below entry in settings.xml file

<useMavenSettingsForAuth>true</useMavenSettingsForAuth>


3. Select your project->maven-> maven build and configure target as below


Click Run. It will build project, build image and push it to your docker hub repository as below.













 
 
 

Recent Posts

See All
RFP PRE/POST-PROPOSAL SUBMISSION FLOW

🏆 1. The 5 Pillars to Win a Large Strategic Deal 1. Understand the Client Better Than They Do 👉 Don’t just read RFP — decode it What is their real problem ? What is driving this deal? (compliance, c

 
 
 
DIGITAL LENDING RFP Solution

🎯 RFP Proposal SOLUTION PRESENTATION – DIGITAL LENDING (WITH COLOR-CODED ARCHITECTURE) 1️⃣ Opening “Thank you for the opportunity. I’ll walk you through our approach to building a next-generation dig

 
 
 

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
  • Facebook
  • Twitter
  • LinkedIn

©2024 by AeeroTech. Proudly created with Wix.com

bottom of page