One-liner & script to stop (and remove) all Compose projects that live in sub-folders.
find . -type f \( -name "docker-compose.yml" -o -name "compose.yaml" \) \
-execdir sh -c 'echo "↓ Stopping in $(pwd)"; docker compose down' \;Paste it at the root of your workspace.
It will descend into every sub-directory containing docker-compose.yml or compose.yaml and rundocker compose downthere.
shutdown-all-docker-compose.sh
#!/usr/bin/env bash
# Shut down EVERY Docker Compose project below the current directory.
set -euo pipefail
find . -type f \( -name "docker-compose.yml" -o -name "compose.yaml" \) \
-execdir sh -c '
echo -e "\n\033[1;34m↓ Stopping Compose project in $(pwd)\033[0m"
docker compose down
' {} \;
echo -e "\n✅ All Compose projects stopped."- Save, then give it permission:
chmod +x shutdown-all-docker-compose.sh - Run from the directory that contains your projects:
./shutdown-all-docker-compose.sh
| Piece | Purpose |
|---|---|
find . |
Start searching from the current directory downward. |
-type f |
Only look at files (not dirs). |
\( -name "docker-compose.yml" -o -name "compose.yaml" \) |
Match either Compose file name. |
-execdir … \; |
For each match, cd to the file’s directory and run the given command. |
docker compose down |
Stop & remove that stack’s containers, networks, and default volumes. |
| Need | Adjustment |
|---|---|
| Dry-run first | Replace docker compose down with echo docker compose down to just list what would happen. |
| Remove named volumes too | Add --volumes: docker compose down --volumes |
| Remove images as well | Add --rmi all |
| Old Compose (v1) | Change docker compose → docker-compose |
Tip: If you want an even deeper clean afterwards, run
docker system prunemanually.
- Docker Compose v2 (CLI sub-command form:
docker compose …). - Bash or POSIX-compatible shell.
- File system where your projects live under a common parent folder.