0% found this document useful (0 votes)
4 views4 pages

Docker for Spring Boot Deployment Guide

Docker is a containerization platform that simplifies application deployment by packaging applications with their dependencies into containers, ensuring consistency across environments. The document provides a step-by-step guide to Dockerizing a Spring Boot application and highlights the advantages of using Docker, such as portability, isolation, and simplified deployment. It also includes a real-world scenario in telecom, demonstrating how Docker can streamline service management.

Uploaded by

rathishkumar022
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views4 pages

Docker for Spring Boot Deployment Guide

Docker is a containerization platform that simplifies application deployment by packaging applications with their dependencies into containers, ensuring consistency across environments. The document provides a step-by-step guide to Dockerizing a Spring Boot application and highlights the advantages of using Docker, such as portability, isolation, and simplified deployment. It also includes a real-world scenario in telecom, demonstrating how Docker can streamline service management.

Uploaded by

rathishkumar022
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

🐳 Docker: Simplifying Application Deployment

Docker is a containerization platform that helps you package, deploy, and run
applications in isolated environments called containers.
Instead of saying, "It works on my machine," Docker ensures it works everywhere
by bundling the application along with its dependencies, configurations, and
libraries into a single container.

🌐 Why Docker? (Real-World Scenario in Telecom) 📡


In your telecom project (Helix platform), you manage services like SIM Activation
and Plan Management.
 Without Docker: Manual setup of Java, Spring Boot, MySQL on every
environment.
 With Docker: Run all services consistently using docker-compose.

⚙️Key Docker Concepts (Simplified)


1. Image: Blueprint of the application (e.g., sim-service:1.0).
2. Container: Running instance of the image.
3. Dockerfile: Instructions to build the image.
4. Docker Compose: Manage multiple containers easily.
5. Volumes: Persistent storage for container data.

Step-by-Step Guide to Dockerize a Spring Boot Java Application 🚀


🔹 1️⃣ Create a Simple Spring Boot App
[Link]
@RestController
@RequestMapping("/api/sim")
public class SimController {

@GetMapping("/activate/{simNumber}")
public String activateSim(@PathVariable String simNumber) {
return "SIM " + simNumber + " activated successfully!";
}
}
[Link]
[Link]=8081

🔹 2️⃣ Create a Dockerfile 🐳


Dockerfile
# 1️⃣ Use an official OpenJDK base image
FROM openjdk:17-jdk-slim

# 2️⃣ Set the working directory


WORKDIR /app

# 3️⃣ Copy the JAR file into the container


COPY target/[Link] [Link]

# 4️⃣ Expose the application port


EXPOSE 8081

# 5️⃣ Run the application


ENTRYPOINT ["java", "-jar", "[Link]"]

🔹 3️⃣ Build and Run the Docker Image


1. Build the JAR:
2. mvn clean install
3. Build the Docker Image:
4. docker build -t sim-service:1.0 .
5. Run the Container:
6. docker run -d -p 8081:8081 sim-service:1.0

🔍 Check the Application:


Open: [Link]

⚙️4️⃣ Docker Compose for Multiple Microservices


[Link]
version: '3.8'
services:
sim-service:
image: sim-service:1.0
ports:
- "8081:8081"
environment:
- SPRING_PROFILES_ACTIVE=prod

plan-service:
image: plan-service:1.0
ports:
- "8082:8082"

mysql-db:
image: mysql:8.0
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: telecom
ports:
- "3306:3306"
Run all services:
docker-compose up -d

⚡ Advantages of Docker 🌟
1. Portability: Run the app anywhere with Docker installed.
2. Isolation: Separate environments for different services.
3. Scalability: Easily scale services using Docker Swarm or Kubernetes.
4. Simplified Deployment: docker-compose automates multi-container
applications.
5. Consistency: Same environment across dev, staging, and production.

Would you like help with Dockerizing multiple microservices or deploying


Dockerized services to AWS ECS? 😊

You might also like