Clean orphan containers#2218
Conversation
There was a problem hiding this comment.
I'd like some feedback from others here. I worry that clean might be too generic and it won't be obvious from the name what it's supposed to do.
|
Thanks for the contribution! Since this is a relative large change (new subcommand, new feature) it may take a little while to get this reviewed and merged, but I think we should include some support for dealing with unmanaged containers. |
|
Thanks for your review :) I will fix the elements you pointed out. |
|
I changed the behavior of
The behavior ps: I just realize that I forgot to add multiple service names in unit test for |
|
Perhaps this should just be a flag on (just my thoughts) |
|
@thaJeztah I think that's a good point. We may not need a whole new subcommand for this. Adding For @cmehay what do you think about dropping the new subcommand and doing this with flags to |
|
@dnephin @thaJeztah I think it would be much safer to add a sub command for this task. I mean, will By the way, if we add a flag to Finally, for |
|
@cmehay (Thinking out loud here) Perhaps we should have a similar approach to how docker handles "dangling" images and volumes; i.e., something like Otoh, this may become too complicated for users, idk |
|
For reference; there has been quite some discussion around implementing a |
|
I updated unit tests and I'm not very happy of what I've done in this method, I tricked with exceptions to list every containers, but the behavior of If you have any suggestion to improve this, you're welcome :) |
|
@thaJeztah regarding the discussion about Regarding |
|
I can't comment on the implementation, but I could really use this feature. When I'm testing a new docker-compose file, I often end up with dozens of orphan, stopped containers. |
|
I would like to say something else to defend the idea of subcommand. I went to a docker meetup with Solomon Hykes few weeks ago, and he said that the important thing of docker is that docker lets people do the way they want to do. I agree with that, people use containers many ways, so I think compose should provide a way to clean unmanaged containers the safer way as possible for the many ways docker is used. Adding flag to existing subcommands if not very safe as these subcommands can alter managed containers, it would be harder to filter services, should display ambiguous informations about containers, and be result legit containers to be stopped or removed...
I really hope people share my point of view, and please let me know if you want me to improve anything in the current implementation. BTW, I'm really sorry about my English, I really hope this is not too painful to read 🙇 |
No worries there, @cmehay, had no problem whatsoever to read! Many (if not most) contributors don't have English as their primary language (including myself) 😄 |
|
The code has been rebased from master. The unit test of Adding I can also change the test to not test with exited container, as you prefer. |
dfd7e45 to
6743760
Compare
This commit adds clean command which provides two options to stop and remove orphan containers. Using --keep only stop running orphaned containers, --force will kill and remove containers without confirmation. ps gets the new flag --all to list orphaned containers, output can be filtered using service names. Service names will match orphan containers if --all flag is present. up gets the new flag --clean to kill orphaned container. This flag will not remove orphaned containers, only clean command will. Signed-off-by: Christophe Mehay <[email protected]>
Signed-off-by: Christophe Mehay <[email protected]>
|
New paradigm on containers and services is driving this MR obsolete. |
This pull request adds to compose a
cleancommand to clean-up orphaned containers whendocker-compose.ymlfile is edited.The first commit adds
cleancommand which provides two options to stop and remove orphan containers. Using--keeponly stop running orphaned containers,--forcewill kill and remove containers without confirmation.psgets the new flag--allto list orphaned containers, output can be filtered using service names. Service names will match orphan containers if--allflag is present.upgets the new flag--cleanto kill orphaned container. This flag will not remove orphaned containers, onlycleancommand will.The second commit adds unit tests about those changes.
Please tell me if any of my edits may alter any good practice about the project.
This is my very first participation on Github to a big project like compose. I really hope I didn't make any mistake in the pull request procedure. Please be indulgent if any :)
Fixes #1477