faradayio / cage

Develop and deploy complex Docker applications
http://cage.faraday.io
Apache License 2.0
307 stars 26 forks source link

Docker warnings about orphan containers #108

Open neezer opened 4 years ago

neezer commented 4 years ago

Trying out cage for the first time, and I'm getting warnings similar to this every time I do cage up:

WARNING: Found orphan containers (publicsearch_redis_1, publicsearch_pg_1, publicsearch_configuration_1, publicsearch_rabbitmq_1) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up.

I've removed all containers from my system and run docker system prune, yet the warnings persist: I get a warning about the containers for each pod that just booted. Cage still seems to work fine despite them, but they sure are annoying. Can something be done about it?

https://asciinema.org/a/3JUPMYfXQ2juMcFyLpOsN2qOq

neezer commented 4 years ago

Looking into this a little further, it seems these are being outputted because the internal docker-compose command for anything cage-related doesn't specify different project names for the pods.

If cage added a -p flag that was pod-specific, I think these would go away. Would also make it so that the automatic generated names for the containers were scoped to both the cage project folder and the pod, eg.

- publicsearch_rabbitmq_1
+ publicsearch_messaging_rabbitmq_1

... where the service rabbitmq was defined in a cage project in pods/messaging.yml.

Otherwise the project names always match, so you'll get warnings for any containers you're not currently executing commands against—at least that's been my experience so far.

See https://stackoverflow.com/questions/50947938/docker-compose-orphan-containers-warning