-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
--profile attribute not respected during 'down' #8139
Comments
I observed the same problem with the |
Any updates on this? This issue seems exist longer than a year now. |
I have the same problem with compose 1.29.2 on Linux (with down and stop) I've started to enjoy the beauty of profiles when I hit this wall :-( |
Just a note on Compose V2: |
In my case, the container included in the profile went down and the network and other containers not included in the profile too. As if I weren't using profiles at all. |
|
@silently just tested with V2: $ docker compose --profile test --profile toto up -d
[+] Running 5/5
⠿ Container truc-toto-1 Running 0.0s
⠿ Container truc-toto-2 Running 0.0s
⠿ Container truc-test-1 Started 0.8s
⠿ Container truc-test-2 Started 0.8s
⠿ Container truc-test-3 Started 0.8s
$ docker compose --profile test down
[+] Running 3/3
⠿ Container truc-test-2 Removed 0.2s
⠿ Container truc-test-1 Removed 0.3s
⠿ Container truc-test-3 Removed 0.3s
⠿ Network truc_default Error |
sorry @ndeloof I got it wrong, just tested with v2.0.0-rc.3 and I have the same behavior |
just tested 2.2.3 and profiles still do not work when using docker-compose down ! I use the latest raspberry pi os, with bullseye and docker, compose 2.2.3 My down command stops every service ! My up command works with compose_profiles |
Latest version 2..3.3 still got this problem... |
Same here with It even seems to have gotten worse, as I was previously testing with I would also add that there should be a Both these features are quite important and the fact that they are missing almost renders the --profile feature useless, or at least certainly much less useful than it can (and should) be. |
The original motivation for profiles was to be able to filter the services that should be started by default, see the discussion in compose-spec/compose-spec#97. For this reason the initial implementation did only affect So E.g. should
The current behavior is 2., since otherwise
For this to work the behavior 1. would need to be implemented. But according to the spec
I.e. the above command would still not only stop/remove services associated with the profile specified, i.e.: web, but all services with the associated profile and all default services - which again is most probably unexpected behavior for the user.
So currently this is actually the expected behavior and in compliance with the spec.
Since all defined services are part of the Compose application model and |
Actually, using compose v2, you can easily address both use-cases: [x] stop and remove only services that are enabled - i.e. have no explicit profile assigned [x] stop and remove all services regardless of the profile |
In order to change the current behavior to achieve the desired results of this issue probably differing behaviors would be required to match with user expectation, which should be docker-compose down # stop and remove *all* defined services - as before
docker-compose --profile web down # stop and remove only services with the `web` profile But the latter introduces new problems with services that are assigned to multiple profiles: should E.g. with this services:
frontend: # our main application
# no explicit profiles, i.e. default
database: # a test database for local development
profiles: ["dev", "debug"]
db_frontend: # a frontend to inspect the test database
profiles: ["debug"]
depends_on:
- database docker-compose up # start only main services, i.e. frontend
docker-compose --profile dev up # start frontend and database
docker-compose --profile debug up # start frontend, database and db_frontend Now, what should
While 1. would not solve this issue here, 2. would come unexpected to the user with docker-compose --profile dev up # start frontend and database for development
docker-compose --profile debug up # additionally db_frontend
docker-compose --profile debug down # intent to only stop db_frontend, but also stops database whereas 3. would be unexpected with docker-compose --profile debug up # start database and db_frontend
docker-compose --profile debug down # intent to stop all services started with previous command, but database is still running Also, what about |
First of all thank you for your rather quick replies. Replying to @acran
I understand that by definition they aren't orphaned as they still are described, but the argument still stands. Replying to @ndeloof
I would argue that the most important and obvious use case is missing. We have base services and services that were started with more than 1 enabled profiles. Now one of the profiles has actually been disabled and there's no easy way to remove the services that should no longer be running. I struggle to see a case where we are interested in removing the base services + the services with profiles we have enabled but NOT the services with profiles that have since been disabled. Replying again to @acran because in the meantime there is a new comment:
I agree with this which is why I feel that the most useful feature that is missing a support for a |
This then should be a separate flag, something like |
I do understand that technically they are not orphans and so it's not completely unsurprising that In fact I see use cases in which both of them can be used so it makes perfect sense that it would be a separate (not exclusive) flag. Is this something that we can add to this project? Like I mentioned on slack feel free to let me know if I can be of help, but unfortunately I have no experience with go which is why a PR hasn't been made by me 😅 |
BTW, apologies if I'm polluting this conversation too much but it would also be very useful (and IMO it should also be a thing) if profiles were added as labels so that they would show up in |
I plan to experiment extending |
From what I understood @acran was arguing for not extending Either way as long as there's progress I'm happy. Please tag me if/when you implement this feature. And as before if I can help in any part do let me know. I'm not sure how hard of an implementation this would be, but if it's not super hard, I could maybe do the PR provided I get some pointers to get me started. |
Was also deceived by this earlier today when running |
This problem still exists? any updates on it? |
yes...
when i use profiles to start services from a compose file the right services start..
But when i want to close a part of the services that are running with profiles, everything stops....
|
I see that unfortunately this hasn't been moving. @laurazard you self-assigned this. Is there something I or someone else can do to move this along? @ndeloof did you end up making any of the experiments that you mentioned? As I mentioned before, I would be happy to help but at least some guidance or a place to start would be appreciated. Thank!! |
Some of the comments above led me to believe that If you land here: don't spend time tinkering with the various workarounds... just change your design. |
Follow-up to my above comment about avoiding profiles and "just change your design". I did that: instead of profiles, I used I wonder whether it's better to use profiles (but have difficulty with If anyone comes up with a clever workaround (until either approach is feature-complete), please post your solution here? |
I was going to start using such compose « profile » feature, but unfortunately after reading current thread, it seems to be bringing more issues on the table compared to what it really brings. Or it’s just an incomplete/partially developed feature (still a wip??) where the main focus has only been around the « up », leaving all the other existing compose commands without good support for profiles, making it irrelevant for most scenarios. @lonix1, I agree with you and I’ll be heading toward avoiding using compose profiles entirely, and change the approach to this common problem of grouping a subset of compose services together, and then ability to « up/start/stop/down/etc » them. I was thinking of either one of these legacy approaches: 1- Classic split of main compose yaml file into multiple ones, so that instead of passing profile(s) to your compose commands, you pass compose yaml file(s). 2- Keep your main compose yaml file as is (no split like in 1-), and manage your groups of services separatly/manually (outside compose landscape basically..). There are multiple ways to achieve this, a few examples could be either having a group/list of compose service names in a separate txt file, or that list of services directly in a shell script variable, it depends on your use case. Then you can provide any of those lists of services to the compose commands: // services are space-separated Of course, each approach has its pros & cons, but perhaps those alternate solutions have a better overall score than the pros & cons of the current partial compose profile solution. Again, it depends on our/your use cases.. |
I seem to have an extra problem with this, by docker-compose contains a custom network, and multiple profiles. If I "up" 2 profiles, one at a time, and then "down" one of them, the network gets removed, and I get this error trying to up anything:
|
The original issue has been addressed and discussions here start going in random directions, which make it impossible for us to offer triage and priorization on the possible fixes we can provide. So I'm closing this issue, you're welcome to create a new one with an explicit use-case as a bug report or feature request @RangelReale please open a dedicated issue then @Frank-D "leaving all the other existing compose commands without good support for profiles" - please clarify what you would expect other commands to offer in a dedicated "feature request" issue |
Description of the issue
I have a set of services that I'd like to generally be "always on", with a subset that I'd like to restart as needed.
Each of these commands works as expected:
docker-compose --profile web up -d
// starts services associated with "web" profile -- works finedocker-compose --profile infrastructure up -d
// starts services associated with "infrastructure" profile -- works fineI'd like this command:
docker-compose --profile web down
to only stop/remove services associated with the profile specified, i.e.: web.
Context information (for bug reports)
Output of
docker-compose version
Output of
docker version
Output of
docker-compose config
(Make sure to add the relevant
-f
and other flags)Steps to reproduce the issue
-profiles
todocker-compose.yml
docker-compose --profile XXX up -d
docker-compose --profile XXX down
Observed result
When
down
is run, ALL services are stopped/removed.Expected result
When
down
is run, only services matching--profile
are stopped/removed.Stacktrace / full error message
Additional information
docker-compose
installed viacurl
(since 1.28.x isn't part of Docker Desktop for Mac yet).Love the possibility that profiles preset! Thanks for your hard work!
The text was updated successfully, but these errors were encountered: