✦ For everyone, free.

Practical knowledge for real and everyday life

Home

19.3.1.4 Df Volume Usage

A focused guide to Df Volume Usage, connecting core concepts with practical Docker and container operations.

The volume usage section within docker system df -v expands the Local Volumes row from the default summary into a per-volume breakdown. For each Docker-managed volume on the host, it shows the volume name, the number of containers currently mounting it, and the amount of disk space it occupies. This section is essential for identifying which volumes are consuming the most storage and distinguishing between volumes actively in use and orphaned volumes that could be safely removed.

Accessing the Volume Usage Section

docker system df -v

The volume usage table appears after the containers section in the verbose output.

Volume Usage Table Structure

Local Volumes space usage:

VOLUME NAME                                             LINKS     SIZE
postgres_data                                           1         512MB
app_uploads                                             0         124MB
redis_data                                              1         38MB
cache_temp                                              0         76MB
a4f3d2b1c5e6d7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4     0         2.1GB
nginx_logs                                              0         45MB
VOLUME NAME

The name assigned to the volume. Named volumes have human-readable names specified at creation with docker volume create --name or in a Docker Compose volumes: block. Anonymous volumes have names that are 64-character hexadecimal strings generated by Docker, making them immediately distinguishable from named volumes in this table.

LINKS

The number of containers currently mounting this volume. This count reflects active links — containers that are currently running and have this volume mounted. Stopped containers that were using the volume do not count toward LINKS.

A LINKS value of 0 means no currently running container is using this volume. However, a stopped container may still reference it. Before removing a volume with 0 links, verify no stopped container references it, or use docker volume prune which only removes volumes not referenced by any container (running or stopped).

A LINKS value of 1 or more means the volume is actively mounted. Removing it while a container is using it is not permitted by Docker without force.

SIZE

The actual disk space consumed by the volume's data. This is the size of the directory at /var/lib/docker/volumes/<volume_name>/_data (on Linux hosts using the local driver).

Volume sizes in this table can be surprising in both directions:

  • A named volume created for a database (like postgres_data) may be hundreds of megabytes or gigabytes, holding all the database files.
  • A recently created but unused volume shows 0B.
  • An anonymous volume with a UUID-style name may be large if an application wrote data to it that was not expected to persist.

Distinguishing Named and Anonymous Volumes

Named volumes have short, recognizable names:

postgres_data        1    512MB
app_uploads          0    124MB

Anonymous volumes have UUID-style names and are typically created automatically by Docker when a container image declares a VOLUME instruction but the container was started without explicitly naming that volume:

a4f3d2b1c5e6d7f8a9b0c1d2e3f4a5b6c7d8e9f0a1b2c3d4     0    2.1GB

An anonymous volume with a large SIZE and 0 LINKS is a strong candidate for review. It may represent data written by a stopped container that was never explicitly managed.

Volumes Not Shown in This Section

Only volumes managed by Docker's local driver appear in this table. Bind mounts (host directories mounted into containers using -v /host/path:/container/path) are not volumes in Docker's sense and do not appear here. They are tracked in the Mounts section of docker inspect but not in docker system df.

Identifying Orphaned Volumes

A volume with LINKS = 0 may be orphaned — not referenced by any container at all. To confirm, check if any container (including stopped ones) references it:

docker ps -a --filter volume=app_uploads

If no container is returned, the volume is truly orphaned and can be safely removed:

docker volume rm app_uploads

To remove all volumes not referenced by any container in one operation:

docker volume prune

With confirmation skipped:

docker volume prune --force

Caution with Named Volumes

Named volumes may hold critical persistent data even when no container is actively using them. A postgres_data volume with LINKS of 0 could mean the database container is simply stopped — the volume still contains all database files. Removing it would destroy the database.

Before running docker volume prune, always inspect the volume list:

docker volume ls

And check the contents of any named volume you intend to remove:

docker run --rm -v postgres_data:/data alpine ls /data

This mounts the volume into a temporary Alpine container and lists its contents, confirming whether it holds data worth preserving.

Practical Example

Given the volume usage table:

VOLUME NAME                                             LINKS     SIZE
postgres_data                                           0         512MB
a4f3d2b1c5e6d7f8...                                    0         2.1GB

Both volumes show 0 LINKS. The correct action differs:

  • postgres_data is a named volume that almost certainly holds database files. Before removing it, confirm the database container is intentionally decommissioned and the data is either backed up or no longer needed.
  • The UUID-named volume is anonymous and likely was created by a stopped container running a Dockerfile with a VOLUME instruction. It may hold nothing critical, but the contents should be inspected before removal.

The volume usage section of docker system df -v is the clearest way to see the disk impact of Docker volumes at a glance and to identify which ones are candidates for cleanup versus which ones hold data that must be preserved.