Inspired by mortenson/composelist.sh.
jq
is required.
Inspired by mortenson/composelist.sh.
jq
is required.
#!/usr/bin/env bash | |
# | |
# Down all running Docker Compose projects | |
# | |
docker ps --filter "label=com.docker.compose.project" -q |\ | |
xargs docker inspect |\ | |
jq -r 'map( .Config.Labels ) | | |
map({" | |
project": ."com.docker.compose.project", | |
"working_dir": ."com.docker.compose.project.working_dir", | |
"config_files": (."com.docker.compose.project.config_files" | split(",")) | |
}) | | |
unique | | |
sort_by(.project) | | |
.[] | | |
"cd " + .working_dir + " && docker compose " + ( .config_files | map("-f " + .) | join(" ")) + " down"' |\ | |
xargs -IXXX bash -c XXX; |
#!/usr/bin/env bash | |
# | |
# List all running Docker Compose projects | |
# | |
docker ps --filter "label=com.docker.compose.project" -q |\ | |
xargs docker inspect |\ | |
jq -r 'map( .Config.Labels ) | | |
map({ | |
"project": ."com.docker.compose.project", | |
"working_dir": ."com.docker.compose.project.working_dir", | |
"config_files": (."com.docker.compose.project.config_files" | split(",")) | |
}) | | |
unique | | |
sort_by(.project)' |