The check runs docker volume ls -f dangling=true --format '{{.Name}}' through the dk helper and counts the non-empty lines that come back. The dangling=true filter is Docker's own definition of a volume that no container currently references, so that name list is the entire input: no size, label, mountpoint or content is read. Zero names is the PASS; one or more is a WARN, with at most the first five names quoted in the message and the count itself complete.
Needs the docker binary and daemon access; otherwise SKIP. It runs a single command - docker volume ls -f dangling=true - which lists volumes no container currently references, and reports at most 5 by name. "Dangling" includes both anonymous volumes left behind when a container was removed and named volumes whose containers no longer exist; the check does not distinguish them, look at their size, or inspect their contents. It is a hygiene and stale-data signal rather than an exposure, hence LOW severity - but a dangling volume can still hold a full database from a removed container.
| Result | When | What it means |
|---|---|---|
| SKIP | Docker missing / daemon unreachable | Nothing was verified. No volume list was ever retrieved, so dangling volumes may well exist unreported. |
| PASS | None | Every volume on this host is referenced by at least one container, so there is no orphaned volume data to review. |
| WARN | One or more dangling volumes | At least one volume is unreferenced and may still hold data from a container that was removed. The message names up to five of them. |
Dangling volumes (no container references them) accumulate from docker run without --rm, recreated Compose services, and images with VOLUME directives. They hold stale data (database files, uploads, secrets) that nobody backs up, rotates, or audits, and they consume disk. Housekeeping per NIST SP 800-190 4.4.4.
- A named volume you created in advance for a service that is not yet deployed is "dangling" until the container exists.
- Compose
downwithout-vleaves named volumes by design (so data survives); they are only dangling if no container references them at audit time, which happens betweendownandup. dangling=truealso includes named volumes, not just anonymous hashes.
List them with their size
sh for v in $(docker volume ls -qf dangling=true); do printf '%s\t%s\n' "$v" "$(sudo du -sh "$(docker volume inspect -f '{{.Mountpoint}}' "$v")" 2>/dev/null | cut -f1)"doneLook inside the ones you do not recognise
The labels name the Compose project and volume that created a volume, if any; anonymous volumes have a 64-character hash for a name and usually no labels.
sh docker volume inspect <name> # check Labels and Mountpointdocker run --rm -v <name>:/mnt:ro alpine ls -la /mntBack up anything worth keeping, then remove
sh docker run --rm -v <name>:/src:ro -v "$PWD":/backup alpine tar czf /backup/<name>.tgz -C /src .docker volume rm <name>Once every remaining dangling volume is one you are sure about, a prune removes them in one go. Without
--allit removes only anonymous volumes;--all(Docker 23 and later) adds named ones.sh docker volume prunedocker volume prune --allStop new ones piling up
Start throwaway containers with
docker run --rm, which removes their anonymous volumes with them. Give volumes names in Compose, so a recreated service reuses its volume instead of leaving the old one behind.
docker volume ls -f dangling=true# expected: no output, or only volumes you decided to keep# Space the remaining volumes use, and how much is reclaimable:docker system df- The check printed one of two messages. "Docker not installed" means
command -v dockerfound nothing on the audit account'sPATH. "Cannot query Docker daemon" means a plaindocker psfailed for the audit account and there was no root or sudo to retry with: run the audit as root, with sudo, or as a member of thedockergroup. The Docker Inventory check reports whether the daemon itself is reachable. - With root or sudo available, a stopped daemon does not produce a SKIP. The check goes on to
as_root docker volume ls, which fails quietly and returns nothing, and an empty list is read as zero dangling volumes. On a host where Docker may be down, runsudo docker volume lsbefore trusting that PASS. - Do not.
docker volume prunedeletes every dangling volume irreversibly, and a database volume becomes "dangling" the moment its container is recreated under a different name or removed during a deploy. Check size and contents with the commands above first. - An image with a
VOLUMEinstruction creates a fresh anonymous volume on everydocker runwithout--rmor an explicit-v. Either usedocker run --rm, or give the volume a name so it is reused rather than orphaned each time. - Dangling volumes are only one source. Check images and build cache too:
docker system df, thendocker image prune/docker builder prune. - The message truncates at 5; the count is complete. Use
docker volume ls -qf dangling=truefor the full list.
