I would like to request a new feature in Spring Boot Docker Compose to support the --project-name parameter, which allows setting a custom project name for Docker Compose.
Currently, Docker Compose uses the name of the current working directory as the default project name. This behavior can be problematic when using a subfolder within a project for the compose.yaml file, as it results in an unexpected project name that doesn’t match the intended name for the Docker Compose environment.
Use Case:
In my project, the compose.yaml file is located within a subfolder. Due to the current behavior, Docker Compose uses the subfolder's name as the project name, which leads to inconsistencies and potential conflicts when managing multiple Docker Compose environments.
For example, if my project structure looks like this:
/my-project
/docker
compose.yaml
Docker Compose would default to using docker as the project name, which is not ideal. I would like to have the ability to set a custom project name directly via Spring Boot’s Docker Compose support, just as you can with the --project-name parameter in Docker Compose.
Suggested Solution:
Enhance the Spring Boot Docker Compose integration to accept a spring.docker.compose.project-name configuration property (default to spring.application.name?), which would be passed as the --project-name parameter to Docker Compose. This would allow users to define a custom project name, ensuring consistency across different environments.
Benefits:
- Consistency: Ensures that the project name is consistent across different environments, regardless of the folder structure.
- Flexibility: Allows developers to organize their project structure more flexibly without being constrained by Docker Compose’s default behavior.
- Compatibility: Aligns Spring Boot’s Docker Compose support with Docker Compose’s native functionality, making it easier for users to manage complex setups.
References:
Docker Compose documentation on the --project-name parameter: Docker Docs - Project Name
Comment From: mhalbritter
Duplicate of https://github.com/spring-projects/spring-boot/issues/41086.