July 7, 2026

Deploy Spring Boot to Kubernetes with Docker Compose and Minikube (2026)

Updated July 7, 2026: Refreshed for Docker Desktop, Minikube 1.33+, and Spring Boot 3.3. Replaces scattered 2019–2022 Kubernetes posts with one canonical 2026 guide. See also the original beginner tutorial.

Learn how to deploy Spring Boot to Kubernetes using Docker Compose for local development and Minikube for a production-like cluster on your laptop. This updated deploy spring boot kubernetes tutorial covers Dockerfile best practices, Kubernetes manifests, and end-to-end testing.

Prerequisites: Basic Spring Boot and command-line familiarity. For the app itself, any Spring Boot REST project works — try the Java 21 virtual threads REST API or RAG chatbot.

Estimated time: 90 minutes. Difficulty: Intermediate.

Architecture Overview

Diagram showing Spring Boot app built with Docker, deployed to Minikube via Deployment and Service resources
From Spring Boot source code to running Pod in Minikube

What You Need

  • Docker Desktop (or Docker Engine + Compose v2)
  • Minikubeinstall guide
  • kubectl — Kubernetes CLI
  • A Spring Boot 3.x project with a health endpoint (/actuator/health recommended)
  • 8 GB+ RAM allocated to Docker/Minikube

Step 1: Create or Use a Sample Spring Boot App

Add Spring Boot Actuator for health checks:

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
management.endpoints.web.exposure.include=health,info
server.port=8080

Verify locally:

mvn spring-boot:run
curl http://localhost:8080/actuator/health
Browser or curl showing Spring Boot actuator health endpoint returning status UP
Actuator health endpoint — required for Kubernetes liveness probes

Step 2: Write a Multi-Stage Dockerfile

Create Dockerfile in the project root:

# Build stage
FROM eclipse-temurin:21-jdk-alpine AS build
WORKDIR /app
COPY pom.xml mvnw .mvn/ ./
RUN ./mvnw dependency:go-offline -B
COPY src ./src
RUN ./mvnw package -DskipTests -B

# Run stage
FROM eclipse-temurin:21-jre-alpine
WORKDIR /app
COPY --from=build /app/target/*.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "app.jar"]

Build and test the image:

docker build -t springboot-demo:1.0 .
docker run -p 8080:8080 springboot-demo:1.0
Terminal showing successful docker build of Spring Boot JAR image with tagged springboot-demo:1.0
Multi-stage Docker build — smaller runtime image with JRE only

For Dockerfile fundamentals, see the earlier guide: Introduction to Dockerfile with Spring Boot.

Step 3: Local Dev with Docker Compose

Create docker-compose.yml for app + MySQL (optional):

services:
  app:
    build: .
    ports:
      - "8080:8080"
    environment:
      SPRING_DATASOURCE_URL: jdbc:mysql://db:3306/demo
      SPRING_DATASOURCE_USERNAME: root
      SPRING_DATASOURCE_PASSWORD: secret
    depends_on:
      - db
  db:
    image: mysql:8
    environment:
      MYSQL_ROOT_PASSWORD: secret
      MYSQL_DATABASE: demo
    ports:
      - "3306:3306"
docker compose up --build

See also: Docker Compose with Spring Boot and Dockerize Spring Boot with MySQL.

Docker Compose project directory structure with Dockerfile and docker-compose.yml for Spring Boot
Docker Compose layout — app and database services

Step 4: Start Minikube Cluster

minikube start --cpus=4 --memory=8192 --driver=docker
kubectl cluster-info
minikube dashboard   # optional — opens Kubernetes dashboard
Kubernetes Minikube dashboard showing running cluster and workloads
Minikube dashboard — verify cluster is healthy before deploying

Step 5: Build and Load the Container Image

Point your shell at Minikube’s Docker daemon so images build inside the cluster:

eval $(minikube docker-env)
docker build -t springboot-demo:1.0 .

Alternatively push to Docker Hub and reference the remote image in your Deployment.

Step 6: Create Kubernetes Deployment and Service

Create k8s/deployment.yaml:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: springboot-demo
spec:
  replicas: 2
  selector:
    matchLabels:
      app: springboot-demo
  template:
    metadata:
      labels:
        app: springboot-demo
    spec:
      containers:
        - name: app
          image: springboot-demo:1.0
          imagePullPolicy: Never
          ports:
            - containerPort: 8080
          livenessProbe:
            httpGet:
              path: /actuator/health
              port: 8080
            initialDelaySeconds: 30
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /actuator/health
              port: 8080
            initialDelaySeconds: 10
            periodSeconds: 5
---
apiVersion: v1
kind: Service
metadata:
  name: springboot-demo
spec:
  type: NodePort
  selector:
    app: springboot-demo
  ports:
    - port: 8080
      targetPort: 8080
      nodePort: 30080

Apply the manifests:

kubectl apply -f k8s/deployment.yaml
kubectl get pods
kubectl get services
Terminal kubectl get pods output showing two springboot-demo pods in Running status
Two replicas running — Deployment scaled successfully

For YAML-only deployment patterns, compare with: Deploy Spring Boot using Deployment YAML.

Step 7: Test the Deployment

minikube service springboot-demo --url
# Or open NodePort directly:
curl http://$(minikube ip):30080/actuator/health

Expected response:

{"status":"UP"}
curl command hitting Minikube NodePort returning Spring Boot actuator health status UP
Health check via Minikube NodePort — deployment verified

Frequently Asked Questions

Should I use Minikube or Docker Compose for Spring Boot?
Use Docker Compose for fast local dev with databases. Use Minikube when you need to test Kubernetes features — Deployments, Services, ConfigMaps, and scaling — before cloud deployment.

Why is my Pod stuck in ImagePullBackOff?
If you built locally with minikube docker-env, set imagePullPolicy: Never. If using Docker Hub, ensure the image name is correct and the cluster can pull it (check kubectl describe pod).

How do I deploy Spring Boot with MySQL on Kubernetes?
Add a MySQL Deployment + PersistentVolumeClaim, pass the JDBC URL via ConfigMap/Secret, and reference them in your app Deployment. See Deploy Spring Boot with MySQL to Minikube.

Can I deploy to Azure instead of Minikube?
Yes. Build and push to a container registry, then deploy to Azure Container Apps or AKS. Follow Deploy Spring Boot API to Azure.

How is this different from the 2021 Kubernetes beginner tutorial?
This 2026 guide consolidates Dockerfile, Compose, and Minikube into one updated path with Java 21, Actuator probes, and links to the new Spring Boot 3 tutorials. The 2019 beginner tutorial remains available for reference.

What about production Kubernetes?
Production adds ingress controllers, TLS, secrets management, CI/CD (GitHub Actions), and observability. Minikube validates manifests; cloud providers handle the control plane.

Next Steps

Learn DevOps hands-on? Join Alkademy for live Docker, Kubernetes, and Spring Boot deployment workshops.



kindsonthegenius

Kindson Munonye is a software engineer and technical author covering machine learning, statistics, REST APIs, Python, and software engineering. He publishes free tutorials on The Genius Blog and live classes on Alkademy.GitHub · LinkedIn · About · Alkademy

View all posts by kindsonthegenius →
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted