How to use CRaC with Spring Boot in a Docker Container

Transcript

Coordinated Restore at Checkpoint (CRaC) is an OpenJDK project designed to reduce the startup and warmup times of Java applications to just milliseconds. This tutorial demonstrates how to use CRaC with Spring Boot applications running in a Docker container. To follow along, you’ll need Docker (ensure it’s up and running) and a Spring Boot application (version 3.2 or later) since CRaC is supported in these versions. For this example, we’ll use the Spring Boot Petclinic application, which can be found on GitHub. Additionally, we’ll use the Liberica Runtime Container with CRaC support, available on Docker Hub and tagged with “CRaC.”
Open the application in your preferred IDE (e.g., IntelliJ IDEA). No modifications to the application code are necessary—simply add the CRaC project dependency to the pom.xml file (assuming you’re using Maven). You’ll also need a Dockerfile for containerizing the application. In the first stage of the Dockerfile, we use the Liberica Runtime Container based on Liberica JDK Lite 21 and Alpaquita Linux with musl support. This container supports CRaC (indicated by the CRaC tag). Here, we copy the project into the image and package it as a JAR file. In the second stage, we use the Liberica Runtime Container based on JRE to create a layered JAR (recommended by Spring). Finally, we assemble all the layers into a new image using Liberica JRE with CRaC support and define the ENTRYPOINT to create a snapshot when the application exits.

Next, we containerize the application using the docker build command and run it in a container. To create a checkpoint, enable the CAP_CHECKPOINT_RESTORE and SYS_PTRACE capabilities using the --cap-add flag. If your Linux kernel version is older than 5.9, you can use the --privileged flag, though it’s not recommended for production. Once checkpointed, the application logs its activity using the CRaC API. Create a fresh image with a checkpoint using the docker commit command and update the ENTRYPOINT to restore the application from the snapshot. Remove the previous container (docker rm -f) and start the application from the snapshot, specifying the port and required capabilities. The application will start in milliseconds. You can launch multiple Petclinic instances in separate containers by specifying unique ports and container names. To verify the application, open it in a browser—it should run without issues. For copy-and-paste code snippets, refer to the dedicated guide linked in the description box of the video.

Summary

CRaC (Coordinated Restore at Checkpoint) is an OpenJDK project designed to significantly reduce startup and warmup times of Java applications to milliseconds. This tutorial demonstrates using CRaC with a Spring Boot application running in a Docker container, specifically the Spring Boot Petclinic app (version 3.2 or later).

About Catherine

Java developer passionate about Spring Boot. Writer. Developer Advocate at BellSoft

Social Media

Videos
card image
Dec 12, 2025
Will AI Replace Developers? A Vibe Coding Reality Check 2025

Can AI replace software engineers? ChatGPT, Copilot, and LLM-powered vibe coding tools promise to automate development—but after testing them against 17 years of production experience, the answer is more nuanced than the hype suggests. Full project generation produces over-engineered code that's hard to refactor. AI assistants excel at boilerplate but fail at business logic. MCP servers solve hallucination problems but create context overload. Meanwhile, DevOps automation actually works. This breakdown separates AI capabilities from marketing promises—essential for teams integrating LLMs and copilots without compromising code quality or architectural decisions.

Videos
card image
Dec 12, 2025
JRush | Container Essentials: Fast Builds, Secure Images, Zero Vulnerabilities

Web-conference for Java developers focused on hands-on strategies for building high-performance containers, eliminating CVEs, and detecting security issues before production.

Further watching

Videos
card image
Dec 30, 2025
Java in 2025: LTS Release, AI on JVM, Framework Modernization

Java in 2025 isn't about headline features, it's about how production systems changed under the hood. While release notes focus on individual JEPs, the real story is how the platform, frameworks, and tooling evolved to improve stability, performance, and long-term maintainability. In this video, we look at Java from a production perspective. What does Java 25 LTS mean for teams planning to upgrade? How are memory efficiency, startup time, and observability getting better? Why do changes like Scoped Values and AOT optimizations matter beyond benchmarks? We also cover the broader ecosystem: Spring Boot 4 and Framework 7, AI on the JVM with Spring AI and LangChain4j, Kotlin's growing role in backend systems, and tooling updates that make upgrades easier. Finally, we touch on container hardening and why runtime and supply-chain decisions matter just as much as language features.

Videos
card image
Dec 24, 2025
I Solved Advent of Code 2025 in Kotlin: Here's How It Went

Every year, Advent of Code spawns thousands of solutions — but few engineers step back to see the bigger picture. This is a complete walkthrough of all 12 days from 2025, focused on engineering patterns rather than puzzle statements. We cover scalable techniques: interval math without brute force, dynamic programming, graph algorithms (JGraphT), geometry with Java AWT Polygon, and optimization problems that need constraint solvers like ojAlgo. You'll see how Java and Kotlin handle real constraints, how visualizations validate assumptions, and when to reach for libraries instead of writing everything from scratch. If you love puzzles, programming—or both—and maybe want to learn how to solve them on the JVM, this is for you.

Videos
card image
Dec 18, 2025
Java 26 Preview: New JEPs and What They Mean for You

Java 26 is the next feature release that brings features for enhanced performance, security, and developer experience. This video discusses the upcoming JDK 26 release, highlighting ten JEPs including JEP 500. JEP 500 focuses on preparing developers for future restrictions on mutating final fields in Java, emphasizing their role in maintaining immutable state. This is crucial for robust programming and understanding the nuances of mutable vs immutable data, especially concerning an immutable class in java. We also touch upon the broader implications for functional programming in Java.