Dockerize Spring Boot Application (Multi-Stage Build)
Learn how to Dockerize Spring Boot applications using Multi-Stage Builds to reduce image size, optimize performance, and configure MySQL networking. In this comprehensive tutorial, we demonstrate the end-to-end process of creating a production-ready Docker image for a Java Spring Boot application. We move beyond basic setups to implement a Multi-Stage Build strategy, significantly reducing the final artifact size by separating the build environment (JDK) from the runtime environment (JRE). Furthermore, this video addresses a critical challenge in container orchestration: establishing communication between a Spring Boot container and a MySQL database container. You will learn how to configure Docker Bridge Networks and utilize Environment Variables to ensure seamless connectivity between services. β For branding and Business inquiries βΊ [email protected] βΊ Join Discord: https://discord.gg/JZmFvSxw π―π― *Subscribe to my Newsletter:* https://learnwithiftekhar.kit.com/ π Resources Mentioned: Join the waitlist for Docker for Java Developers here: https://learnwithiftekhar.kit.com/docker-for-java-developers π§βπ» Source Code: https://github.com/learnwithiftekhar/spring-boot-crud-rest-api π Here are the tools and resources I use in my videos: π Master programming by recreating your favorite technologies: https://app.codecrafters.io/join?via=learnwithiftekhar βΊ Tool that I use for screen recording: CleanShot X for Mac * cleanshot.sjv.io/bODOab β Background sound: https://share.epidemicsound.com/ia954g π» *Running Windows on Mac? Get Parallels Desktop with a 20% discount!* π *Use code PARALLELS20 and grab it here:* https://parallels.sjv.io/bOVD3M IDE I use for coding * IntelliJ Idea Ultimate * VsCode * Sublime π Secure your connection with NordVPN: https://nordvpn.sjv.io/o4zYan Chapters: 00:00 Intro 01:47 Project Overview 04:20 Configuring Environment Variables 06:09 Creating the Dockerfile 07:18 Stage 1: Download Dependencies 10:07 Stage 2: Build the Application 11:05 Stage 3: Run the Application 13:21 Building & Versioning the Image 15:49 Running the container 16:25 Common Error: Why Localhost Fails 17:24 Setting up Docker Networks 19:10 Running the Container (Passing Env Variables) 20:20 Testing the API π€ In case you want to contact me: β My LinkedIn profile: https://www.linkedin.com/in/hossain-md-iftekhar/ β My X / Twitter profile: https://twitter.com/ifte_hsn β Github: Github: https://github.com/learnwithiftekhar *Note:* Some of the links in this description are affiliate links, and I may earn a small commission if you make a purchase through them. Thank you for your support.
Download
1 formatsVideo Formats
Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.