volume

docker volume

Manages persistent named volumes for containers — create, list, inspect, remove, and prune. Named volumes survive container removal and are the recommended storage mechanism over bind mounts for stateful data.

docker volume COMMAND

Common flags

Flag Purpose
-d, --driver Volume driver (default local)
--name Explicit volume name on create
-o, --opt Driver-specific options (e.g., type=nfs)
-f, --force Force removal without confirmation
--filter Filter output on ls/prune (e.g., dangling=true)

Examples

docker volume create pgdata

Create a named volume

docker run -v pgdata:/var/lib/postgresql/data postgres:16

Mount the named volume into a container

docker volume inspect pgdata

Show mountpoint and driver metadata

docker volume prune

Remove all volumes not referenced by any container

Gotcha

docker rm -v only removes ANONYMOUS volumes — named volumes must be deleted explicitly. On Docker Desktop the volume mountpoint lives inside the VM, so browsing /var/lib/docker/volumes from the host won't work.

Related commands

← All Docker commands · Docker vs Kubernetes · Docker vs VMs