New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect Handling of Active Profiles in Docker Compose Integration #39841
Comments
The profiles are used to decide which services, if any, Spring Boot's integration should start. If one or more of the services in the compose.yaml file is already running, this step is skipped and Spring Boot uses all of the already running services. Why are you manually starting the services rather than allowing Spring Boot to control their lifecycle? If you omit this step, I believe things should works as you want. Would that meet your needs? |
Adding to that, I'm not sure we can find out when the services are running to what profile they belong, so filtering them on the profile after they have been started might not be possible. |
@wilkinsona, I encountered an issue in one of my practice projects with three applications (authorization, client, and resource), each requiring a separate database (hence, multiple DB services). I've organized the project with the following structure:
You can find the project on GitHub: oauth2. The goal is for the authorization application to use only the The authorization application should exclusively utilize the I believe there are two issues at play here:
|
Thanks for the additional details. The profile matching may not be working as you would like but it is working as expected and, unfortunately, I don't think it will be possible for us to make it work as you would like. We use For your situation where you have three separate apps and three separate services, I think you would be better using three separate compose.yaml files, one for each app. I also think it would align more closely with the spirit of the Docker Compose documentation and the recommendation that "the core services of your application shouldn't be assigned profiles so they are always enabled and automatically started". As far as I can tell, your current approach relies on every service being assigned to a profile. |
@wilkinsona Originally, I intended to employ individual |
Issue Description:
When using Docker Compose in combination with Spring Boot and defining multiple services with profiles in the
compose.yaml
file, there seems to be an issue with the Spring Boot behavior when specifying an active profile. Specifically, even if only one profile is specified, Spring Boot is considering all the services, leading to unexpected behavior.Steps to Reproduce:
docker-compose.yaml
file.spring.docker.compose.profiles.active=server
(or any other specific profile).Expected Behavior:
When specifying an active profile, Spring Boot should only consider the services associated with that profile, and ignore the others.
Actual Behavior:
Spring Boot is considering all services, leading to conflicts, as illustrated by the following error message:
Additional Information:
Possible Solution:
Ensure that Spring Boot correctly filters and activates only the services associated with the specified active profile in Docker Compose.
Note:
This issue is causing inconvenience in managing profiles and services, and a resolution is highly appreciated.
The text was updated successfully, but these errors were encountered: