compose icon indicating copy to clipboard operation
compose copied to clipboard

Stop containers that have been removed from docker-compose.yml

Open matschaffer opened this issue 11 years ago • 5 comments

Apologies if this is covered somewhere, but I wasn't able to find anything.

The new --x-smart-recreate is working really nicely for changes to running containers and new containers, but if I remove a container from container from the YAML definition it just stays running.

It'd be fantastic to support automatic removal if that's at all possible.

matschaffer avatar May 29 '15 02:05 matschaffer

Thanks for trying the RC!

You're right - we never remove stuff that's been deleted from the YAML. I think that's actually a sensible strategy for docker-compose up - we should always be careful about automatically removing containers.

Perhaps there should be a docker-compose cleanup command, which prompts you before removing anything.

aanand avatar May 29 '15 08:05 aanand

That does make sense. So long as we can have a -f that doesn't require interaction a 'cleanup' sounds great!

On Friday, May 29, 2015, Aanand Prasad [email protected] wrote:

Thanks for trying the RC!

You're right - we never remove stuff that's been deleted from the YAML. I think that's actually a sensible strategy for docker-compose up - we should always be careful about automatically removing containers.

Perhaps there should be a docker-compose cleanup command, which prompts you before removing anything.

— Reply to this email directly or view it on GitHub https://github.com/docker/compose/issues/1477#issuecomment-106736038.

-Mat

about.me/matschaffer

matschaffer avatar May 29 '15 10:05 matschaffer

I suggest a new command 'diff' that prints out an explanation of what 'up' is going to do. That way if 'up' is going to remove a container you get a way of finding out first.

Because docker compose adds labels I consider those containers are under it's 'control', and I would be happy for 'up' to remove anything that it doesn't find in the yaml file. I believe it's a natural extension to --x-smart-recreate - a --x-smart-remove.

tcoats avatar Jun 19 '15 03:06 tcoats

We should do something with the containers. Anything with a project label that matches, but a service label that doesn't could be considered an orphaned container. We should provide a way to prune those.

dnephin avatar Sep 29 '15 03:09 dnephin

I'm working on this feature 294ecb21a841f10075ebda8afb2017e3d8e856f9

I still need to write unit tests, so I can't ask for a merge request right now, but if you have any observations about this work, they are very welcome :grinning:

cmehay avatar Oct 12 '15 22:10 cmehay