Skip to content

Allow configuration of container host via Spring Boot property (e.g. spring.docker.compose.host) #46683

@julien92

Description

@julien92

Context

We are currently migrating our GitHub Actions CI pipeline from GitHub-hosted runners to self-hosted
runners that run as pods inside our Kubernetes infrastructure.

We use spring-boot-docker-compose (introduced in Spring Boot 3.1) as part of our pipeline to
manage application containers.

However, our environment is a Docker-in-Docker (DinD) setup. This means the services launched by
docker-compose are not accessible via localhost, but only through the Docker bridge IP (
172.17.0.1, for example).

Currently, spring-boot-docker-compose assumes services are reachable on localhost, and has no
mechanism to distinguish between:

  • Docker on local VM (e.g., Docker Desktop or normal Docker engine)
  • Docker-in-Docker (common in CI/CD or Kubernetes runners)

This leads to connection issues in pipelines when services are not reachable via localhost.

Proposal

We propose that spring-boot-docker-compose supports a new Spring Boot property to explicitly
define the service host IP that Spring Boot should use when accessing the container from outside.

For example:

spring:
  docker:
    compose:
      host: 172.17.0.1

This would let users explicitly tell Spring Boot what host to use when generating dynamic service
URLs, particularly in CI/CD environments where assumptions about localhost do not hold.

This approach allows the property to be overridden using:

  • Spring profiles (e.g., application-ci.yaml)
  • Environment variables (e.g., SPRING_DOCKER_COMPOSE_HOST=172.17.0.1)
  • Command line arguments (e.g., --spring.docker.compose.host=172.17.0.1)

Benefits

  • Works seamlessly in Docker-in-Docker environments.
  • Avoids hardcoding workaround logic in build scripts or dynamic property sources.
  • Keeps docker-compose.yml clean and environment-agnostic.
  • Improves compatibility with pipelines that use Spring Boot Docker Compose support.

Thank you for considering this improvement.

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