Skip to content

Instantly share code, notes, and snippets.

@mortenson
Last active November 5, 2023 13:38
Show Gist options
  • Star 26 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save mortenson/538027ef218a52e190be7b9b2c17a3ca to your computer and use it in GitHub Desktop.
Save mortenson/538027ef218a52e190be7b9b2c17a3ca to your computer and use it in GitHub Desktop.
List all Docker Compose projects currently running
#!/bin/bash
docker ps --filter "label=com.docker.compose.project" -q | xargs docker inspect --format='{{index .Config.Labels "com.docker.compose.project"}}'| sort | uniq
@EriksonBahr
Copy link

thanks!

@daveisfera
Copy link

daveisfera commented Nov 11, 2019

You need to throw a sort in before the call to uniq to ensure that you don't end up with duplicates because of order

@mortenson
Copy link
Author

@daveisfera done! thanks

@conclusionlogic
Copy link

or just use sort -u

@stephankn
Copy link

thanks

@ohihn
Copy link

ohihn commented Jan 24, 2023

Also works for me, is a little bit shorter

docker compose ls --format json | jq '.[].Name' -r

@robozb
Copy link

robozb commented Aug 2, 2023

Thank you so much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment