brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: docker compose ls lists every Compose project on the host

Docker
~/tips/tip-docker-compose-ls-all-projects

docker compose ls

Lists the Compose projects running on this host, so you can find one without remembering its folder.

Compose commands only work inside the project folder, or with the right -f and -p. When you forgot where a stack lives, docker compose ls tells you.

docker compose ls
docker compose ls -a

It lists the Compose projects that are currently running, with the status and the path of the config file. -a (--all) includes stopped projects as well, which matters when you want to find something you shut down months ago.

The output has more options. --format json gives machine-readable output, -q prints just the project names and --filter narrows the list, for example by status.

docker compose ls --format json

The config file path is the useful part: from there you can cd to the folder, or run docker compose -f /path/to/compose.yaml ps from anywhere.

The caveat is that the list only knows projects that Compose started, based on the labels it puts on containers. A container that was started with plain docker run is not listed, and a project whose containers were removed manually disappears from the list even if the compose file is still on disk. In that case look for the folder yourself.

Further reading: docker compose ls reference

More Docker tips ONBUILD RUN /usr/local/bin/python-build --dir /app/src SHELL ["/bin/bash", "-c"] docker commit <container> myname/testimage:version3 docker import /path/to/exampleimage.tgz docker compose events All Docker tips (192) All topics

Link