Spring Boot Tutorial 0/110 lessons ~6 min read Lesson 74

    Docker for Microservices

    Each microservice ships as a Docker image.

    Course progress0%
    Focus
    2 guided sections
    Practice signal
    Examples included
    Career prep
    Foundation builder

    Introduction

    Each microservice ships as a Docker image. Spring Boot 3 can build OCI images directly with Cloud Native Buildpacks — no Dockerfile needed.

    Informative example

    bash
    # Build with buildpacks (no Dockerfile!)
    ./mvnw spring-boot:build-image -Dspring-boot.build-image.imageName=acme/orders:1.0.0
    # Or a hand-rolled multi-stage Dockerfile
    # ──────────────────────────────────────
    FROM eclipse-temurin:21-jdk AS build
    WORKDIR /app
    COPY . .
    RUN ./mvnw -q -DskipTests package
    FROM eclipse-temurin:21-jre
    WORKDIR /app
    COPY --from=build /app/target/*.jar app.jar
    EXPOSE 8080
    USER 65532
    ENTRYPOINT ["java","-jar","/app/app.jar"]
    Ready to mark this lesson complete?Track your journey across the entire course.