DEV Community

Cover image for Docker Boot - Spring Boot Docker Container Management Made Easy
Eddie
Eddie

Posted on

1

Docker Boot - Spring Boot Docker Container Management Made Easy

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
Enter fullscreen mode Exit fullscreen mode
  • 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
Enter fullscreen mode Exit fullscreen mode

🎯 Event-Driven Container Management

@Service
public class DockerService {
    private final ApplicationEventPublisher eventPublisher;

    public void startContainer() {
        eventPublisher.publishEvent(
            new DockerContainerEvent(this, Action.START)
        );
    }
}
Enter fullscreen mode Exit fullscreen mode

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

  1. Add dependency:
implementation 'io.github.ddaakk:docker-container-spring-boot-starter:0.2.0'
Enter fullscreen mode Exit fullscreen mode
  1. Configure containers:
docker:
  containers:
    redis:
      enabled: true
      container-name: my-redis
      image-name: redis:latest
Enter fullscreen mode Exit fullscreen mode
  1. 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.

Billboard image

Imagine monitoring that's actually built for developers

Join Vercel, CrowdStrike, and thousands of other teams that trust Checkly to streamline monitor creation and configuration with Monitoring as Code.

Start Monitoring

Top comments (0)

Heroku

This site is powered by Heroku

Heroku was created by developers, for developers. Get started today and find out why Heroku has been the platform of choice for brands like DEV for over a decade.

Sign Up

πŸ‘‹ Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay