Skip to content

It is unclear that Docker Compose services have not been started as one or more is already running #38398

@lianej

Description

@lianej

Version: spring-boot-docker-compose:3.1.2

I have created a project using spring-boot-docker-compose that lists three services (let's call them A, B, and C) in the compose.yml file. Everything works as expected on the first launch.

However, after the containers are created, if I manually start the container for service A using the Docker API (docker start $service_A_container_id), and then attempt to start the Spring application again without first stopping it, the spring-boot-docker-compose skips the container startup phase. This results in services B and C not being started correctly.

Upon inspecting the code, I found the cause of this issue lies in the condition used to determine whether the Docker API should be called in org.springframework.boot.docker.compose.lifecycle.DockerComposeLifecycleManager#start:

if (lifecycleManagement.shouldStart() && runningServices.isEmpty()){
    ...
}

This condition stipulates that no currently running services should be found.

I believe the startup phase should not be skipped in this scenario for the following reasons:

  1. If the service I'm starting is a database, there are instances where I would want to connect to the database to inspect data without needing to start the entire application. This necessitates the ability to start the container independently.
  2. The Docker-Compose API supports the restarting of already started containers. Hence, removing the restriction to skip startup wouldn't lead to any errors.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions