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 volumes lists the volumes a project uses

Docker
~/tips/tip-compose-volumes-list

docker compose volumes

Lists the volumes of a Compose project, per service if you like, with a custom format.

I always forget which volumes belong to which stack. Counting on the volume name prefix works until two projects share a prefix. Compose can answer the question itself.

docker compose volumes
docker compose volumes web
docker compose volumes -q

The command prints the volumes of the project, and with a service name at the end only that service’s volumes. -q or --quiet prints only the names, which is useful in a script. The docs give no sample output, so I won’t show one here.

The --format option accepts table (the default), table TEMPLATE, json or a plain Go template. For example, --format json gives output that jq can read, and a template lets you pick only the columns you care about. The docs point to the general formatting page for the template syntax.

A use I’d have for it: before I run docker compose down -v, I list the volumes first to see what would go. Together with docker compose config you know both what the file declares and what exists.

The caveat is that it only covers one project. Like the other Compose commands it works on the project it finds from the current directory or from -p and -f, so run it from the project folder.

Further reading: docker compose volumes

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