Skip to content

Add a property to enable/disable service connection in Docker Compose Support #46590

@doljae

Description

@doljae

Description

Spring Boot provides Docker Compose support, which automatically creates ServiceConnection instances based on the services defined in a docker-compose.yml file. These connections override the default connection settings of the Spring Boot application, which can be very convenient.

However, this behavior can cause issues in certain scenarios, making it difficult to use an existing docker-compose.yml as-is.

For example, when using Redis, a RedisDockerComposeConnectionDetails instance is created internally. If the container does not use the default Redis port (6379), this leads to an exception at runtime. Similar problems can arise with other services or due to both technical and non-technical reasons affecting the docker-compose.yml.

Some users may simply want to reuse their existing docker-compose.yml to manage service lifecycles in conjunction with the Spring Boot application, without necessarily leveraging the automatic service connection feature.

Proposal

Introduce a new property that allows users to disable the automatic creation of service connections from Docker Compose.

This would provide greater flexibility, enabling users to:

  • Run existing docker-compose.yml files without modification.
  • Opt out of automatic service connection behavior when not needed.
  • Still benefit from Docker Compose lifecycle management.

Example

spring:
  docker:
    compose:
      service-connection:
        enabled: false

This addition would allow developers to integrate Docker Compose into their Spring Boot applications in a more controlled and adaptable way.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions