DevOps Java Docker

Spring Boot on Docker: Complete Step-by-Step Containerization Guide

Containerize Spring Boot with Docker: Single and Multi Stage Dockerfile, Healthcheck, environment variables, Dev/Prod configurations and container lifecycle.

Course description

Spring Boot on Docker: Containerize Your API Step by Step

Knowing how to write a Spring Boot application is one thing — knowing how to containerize it correctly with Docker is another. In this course we build a complete journey from the first containerization of a simple REST API all the way to managing separate Dev and Prod configurations, integrated Healthchecks and environment variables. Every step is hands-on, every decision is explained.

What You'll Learn

  • Creating a Spring Boot REST API and containerizing it with Docker from the first image
  • Structuring a Single Stage Dockerfile: what it does, advantages and use cases
  • Moving to a Multi Stage approach for lighter, more secure and modular images
  • Understanding the Docker container lifecycle: creation, execution, termination
  • Using cURL to test endpoints of a containerized REST API
  • Adding a Healthcheck to the Dockerfile with cURL to monitor application availability
  • Managing separate Dev and Prod configurations with Spring profiles and environment variables
  • Passing Environment Variables to the container to configure the application at runtime

From Local Build to Deploy-Ready Container

Containerization is not just "putting the app in a box" — it's a process that impacts architecture, configuration and the development lifecycle. This course teaches you to do it right: optimized images, working Healthchecks, configurations that change between environments without modifying code. The right starting point for anyone who wants to bring their Spring Boot APIs to production with Docker.

Who This Course Is For

Designed for Java developers with Spring Boot experience who want to learn how to containerize their applications. Basic knowledge of Docker (images and containers) is required. Not suitable for those who have never used Spring Boot.

Lessons list

In this lesson we create a simple Spring Boot REST API and containerize it with Docker: from Spring Initializr project setup all the way to the first working image and a running container.

Guarda lezione

I'll show you how to structure a Single Stage Dockerfile for a Spring Boot application: what each FROM, COPY, RUN, and CMD instruction does, the advantages of this approach, and when it makes sense to use it.

Guarda lezione

We'll go deeper into the Single Stage Dockerfile for Spring Boot, analyzing critical points, important configuration details not to overlook, and common mistakes that slow down or break containerization.

Guarda lezione

I'll introduce Multi Stage builds in Docker: how to separate the Maven compilation phase from the runtime phase to produce lighter, more secure, and optimized Spring Boot images.

Guarda lezione

We'll go deeper into the Multi Stage Dockerfile for Spring Boot with additional practical cases: layer caching optimizations, strategies to reduce image size, and how to make the build more modular.

Guarda lezione

Let's walk through the complete lifecycle of a Docker container applied to a Spring Boot application: from image creation with docker build, to execution with docker run, through to stopping and removing the container.

Guarda lezione

I'll show you how to use cURL from the terminal to quickly test your containerized Spring Boot REST API endpoints, with practical commands for GET and POST requests without needing any graphical tools.

Guarda lezione

In this lesson we add a HEALTHCHECK instruction to the Spring Boot Dockerfile using cURL: I'll configure the interval, timeout, and retry threshold to automatically monitor the app's availability inside the container.

Guarda lezione

We'll go deeper into the Dockerfile HEALTHCHECK for Spring Boot with practical examples: optimizing interval and startup-period parameters, analyzing status logs, and avoiding false negatives in production.

Guarda lezione

Let's see how to manage separate Dev and Prod configurations in a Dockerized Spring Boot app, using Spring profiles (application-dev.yml, application-prod.yml) that can be activated via environment variables.

Guarda lezione

I'll show you how to pass environment variables to the Docker container using the -e flag and a .env file, configuring Spring Boot differently between development and production without modifying code or rebuilding the image.

Guarda lezione
Giovanni Pace

Giovanni Pace

Ingegnere Informatico · Pratola Peligna

  • 107 Courses
About the teacher

Sono un ingegnere informatico con oltre 15 anni di esperienza nel settore ICT. Mi occupo di sviluppo software, cybersecurity, data science e intelligenza artificiale, con particolare attenzione all’innovazione e all’automazione dei processi aziendali. Da anni svolgo anche attività di docenza e formazione, creando percorsi pratici e coinvolgenti su programmazione, DevOps, AI e sicurezza informatica.

This course includes

  • Lessons 11
  • Duration 2h 8m
  • Difficulty intermedio
  • Language it
  • Certificate No

Recently viewed