-
Notifications
You must be signed in to change notification settings - Fork 40.8k
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
Docker compose: add configuration setting for selecting running services to bind #35059
Comments
You can ignore services by labelling them with |
I didn’t know about that, and it might be useful, but not in general. Imagine I want to switch between 2 services for independent tests, for example - it would be awkward to have to edit the compose config in between test invocations. |
The I'm not opposed to adding something but I don't think there's a compelling use case yet. |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
I don't know why the use case I mentioned isn't enough to at least keep the issue open. |
I was thinking about this one the other day and I wonder if we could offer a way to apply labels the spring:
docker:
compose:
labels:
my-service:
org.springframework.boot.ignore: true |
That would work, but why does it work better than simply listing the services you want to bind? To me it makes sense that I am mirroring the docker-compose command line (like with profiles). "I tell you where to find the YAML and what arguments to add to docker-compose, you run it for me." Labels seem like an unnecessary (in this case) indirection. |
The main reason behind my thinking was we could support the other labels (such as |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Big +1 to this
In my case, we have a few different repos that each define their own compose file for how to run that service. Our compose file for ServiceA has something like
This means that to run this particular compose file I'd need to add ignore labels to the other repos compose file, which I don't want because it would mean the other service won't create service connections. Specifying which containers to bind to will also mean changes to service names or the addition/removal of services in the included compose does not affect my settings unless I explicitly bind to external containers |
I do like what @dsyer is proposing |
We have a use-case. I understand it's not meant for testing. However, we have in our dockerfile how to run the app being built for the same project. Also we have the postgres db.
When running in gradle/intellij directly, or when running integration tests, it would useful to be able to specify only the db should be spinned up. However, in other scenarios we'd also like to use docker-compose to spin up both, through docker compose (not through spring). I think we can work around this by using docker compose profiles. But we have a convention across our many projects that running |
@philwebb @wilkinsona main...nosan:spring-boot:35059 Or maybe passing void up(LogLevel logLevel, List<String> arguments, Set<String> services); |
With Boot 3.4, this can be achieved using the general support for passing arguments to the "start" command ( Consider this compose file: services:
mysql:
image: 'mysql:latest'
environment:
- 'MYSQL_DATABASE=mydatabase'
- 'MYSQL_PASSWORD=secret'
- 'MYSQL_ROOT_PASSWORD=verysecret'
- 'MYSQL_USER=myuser'
ports:
- '3306'
postgres:
image: 'postgres:latest'
environment:
- 'POSTGRES_DB=mydatabase'
- 'POSTGRES_PASSWORD=secret'
- 'POSTGRES_USER=myuser'
ports:
- '5432' Starting the application normally will launch containers for both MySQL and Postgres:
To start only
The arguments are a list so you can specify multiple services using a comma-separated value of YAML's list syntax as needed. @mroche89 @dsyer please give this a try with Boot 3.4 and let us know if it meets your needs. I used 3.4.0-SNAPSHOT but the feature's available in 3.4.0-M3 if you'd prefer something that isn't a moving target. @mroche89, milestones are available from https://repo.spring.io/milestone (and snapshots from https://repo.spring.io/snapshot). |
I think |
Thanks for trying it, Dave.
No, we have
You can use I'll leave this open to see how @mroche89 (or anyone else who was interested in this feature) fares, but it's looking like we're good here and will be able to close this one as having been superseded by #42571 and #38763 |
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed. |
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue. |
I have a docker-compose.yml that starts multiple services but I only want to bind to one (or some) of them. It is possible to do that currently by re-arranging the compose file into "profiles" and setting
spring.docker.compose.profiles.active
. But I might not be able to do that for an arbitrary set of services (and I might not want or be able to edit the compose file either), so it would be nice to be able to simply list (or pattern match) the services to bind to.The text was updated successfully, but these errors were encountered: