This guide assumes that you use Spring Boot Docker Compose support.
A prerequisite of this approach is that your development machine has a Docker environment, such as Docker Desktop, available.
Add a dependency spring-boot-docker-compose that does the following:
-
Search for a
compose.ymland other common compose filenames in your working directory -
Call
docker compose upwith the discoveredcompose.yml -
Create service connection beans for each supported container
-
Call
docker compose stopwhen the application is shutdown
To use Docker Compose support, you need only follow this guide.
Based on the dependencies you pull in, Spring Boot finds the correct compose.yml file and start your Docker container when you run your application.