-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Description
Description
I would like an option to have a single command removing all containers, volumes, orphans, network for a given compose file. I thought docker compose down -v -t 0 --remove-orphans does this but as experienced it does not work with profiles. #13027
Example in which this would be useful:
- Setup:
services:
foo:
image: alpine
command: tail -f /dev/null
stop_grace_period: 1s
bar:
profiles:
- manual
depends_on:
- foo
image: alpine
command: tail -f /dev/null
stop_grace_period: 1s- commands:
docker compose up -d bardocker compose down -t 0 -v --remove-orphans
- I expected that all containers for this compose project are wiped. But container bar is still there, also blocking network removal and could also block volumes.
What is the issue with this?
There is always additional knowledge required to wipe a running compose project. E.g. for a random project maybe having different profiles in it you would need something like COMPOSE_PROFILES=$(docker compose config --profiles | tr '\n' ',') docker compose down -t 0 -v --remove-orphans which is the only way of truly resetting it in a generic way.
Proposing --all for down which including all containers for the compose project, like: docker compose down -t 0 -v --all, all should include orphans by default. This would be consistent with other commands which provide --all for docker / docker compose e.g. ps or prune, so I already expected it to exist for down.