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.

原文链接:Docker Boot – Spring Boot Docker Container Management Made Easy

© 版权声明
THE END
喜欢就支持一下吧
点赞15 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容