Docker Boot - Spring Boot Docker Container Management Made Easy
Hey Spring developers! 👋
I've created a library called Docker Boot that makes Docker container management in Spring Boot applications super easy. If you've ever wanted more control over your Docker containers than Spring Boot Docker Compose offers, this might be interesting for you! I would greatly appreciate it if you could give a star on GitHub. Thank you so much!
What is Docker Boot?
Docker Boot is a Spring Boot starter that provides programmatic control over Docker containers with Spring-native configuration. Think of it as a bridge between Spring Boot and Docker with some extra features.
Key Features
🔄 Flexible Lifecycle Management
docker:
containers:
redis:
lifecycle-mode: START_AND_STOP # or START_ONLY, NONE
-
START_AND_STOP
: Full container lifecycle management -
START_ONLY
: Start with app but keep running after shutdown -
NONE
: Manual control only
📝 Spring-Native Configuration
docker:
containers:
postgres:
enabled: true
container-name: postgres-dev
image-name: postgres:14
ports:
5432: 5432
environment:
POSTGRES_DB: devdb
🎯 Event-Driven Container Management
@Service
public class DockerService {
private final ApplicationEventPublisher eventPublisher;
public void startContainer() {
eventPublisher.publishEvent(
new DockerContainerEvent(this, Action.START)
);
}
}
Why Use Docker Boot?
Advantages over Spring Boot Docker Compose:
- Programmatic control through Java API
- Event-driven container management
- Fine-grained lifecycle control
- Deep Spring integration
Perfect for:
- Microservices development
- Integration testing
- Development environments
- Production container management
Getting Started
- Add dependency:
implementation 'io.github.ddaakk:docker-container-spring-boot-starter:0.2.0'
- Configure containers:
docker:
containers:
redis:
enabled: true
container-name: my-redis
image-name: redis:latest
- Run your app!
Links
Looking for Contributors!
If you're interested in contributing or have suggestions, feel free to:
- Create issues for bugs or features
- Submit pull requests
- Share your use cases
- Provide feedback
Let me know what you think! Would love to hear your thoughts and suggestions for improvement.
Top comments (0)