docker-volume
Manage persistent data volumes with Docker
TLDR
Create a volume
Create a volume with a specific label
Create a tmpfs volume a size of 100 MiB and an uid of 1000
List all volumes
Remove a volume
Display information about a volume
Remove all unused local volumes
Display help for a subcommand
SYNOPSIS
docker volume [OPTIONS] COMMAND
PARAMETERS
create
Creates a new volume.
Usage: docker volume create [OPTIONS] [VOLUME_NAME]
Common Options: -d, --driver (specify volume driver, e.g., 'local'), --label (set metadata), --opt (set driver-specific options).
ls
Lists all existing volumes.
Usage: docker volume ls [OPTIONS]
Common Options: -f, --filter (filter output), --format (pretty-print using Go template), -q, --quiet (only display volume names).
inspect
Displays detailed information about one or more volumes.
Usage: docker volume inspect [OPTIONS] VOLUME [VOLUME...]
Common Options: -f, --format (pretty-print using Go template).
rm
Removes one or more volumes.
Usage: docker volume rm [OPTIONS] VOLUME [VOLUME...]
Common Options: -f, --force (force removal of a volume, even if in use).
prune
Removes all unused local volumes.
Usage: docker volume prune [OPTIONS]
Common Options: -f, --force (do not prompt for confirmation), --filter (filter volumes to prune).
DESCRIPTION
docker volume provides commands to manage data volumes, which are the preferred mechanism for persisting data generated by and used by Docker containers. Volumes are independent storage units managed by Docker, ensuring data persists even after containers are stopped or removed. They offer better performance, portability, and backup capabilities compared to bind mounts. This command allows users to create new volumes with specific drivers and options, list existing ones, inspect their detailed configuration and usage, remove them permanently, and prune unused volumes to reclaim disk space on the Docker host. It is a crucial tool for managing stateful applications within the Docker ecosystem.
CAVEATS
Volumes consume disk space on the Docker host; regularly pruning unused volumes is recommended.
Removing a volume is a permanent action and deletes all associated data. Use with caution.
The default 'local' driver stores data directly on the host's filesystem; other drivers can integrate with network storage solutions.
Managing file permissions within volumes can sometimes be complex, often requiring consideration of the user/group IDs inside the container.
VOLUME DRIVERS
docker volume supports different volume drivers (e.g., 'local', or third-party plugins). Drivers determine where and how the volume's data is stored, enabling capabilities like network storage, cloud storage integration, or advanced data management features. The default driver is 'local', which stores volumes on the Docker host's filesystem.
DATA PERSISTENCE
Volumes are designed for data persistence. Unlike data stored within a container's writable layer, data in a volume exists independently of the container's lifecycle. This means data can be safely shared between multiple containers, backed up, or migrated without being affected by container creation, stopping, or removal.
HISTORY
The concept of Docker volumes was introduced early in Docker's development as a more robust and portable alternative to basic bind mounts for managing persistent data. Over time, it evolved to support various volume drivers, allowing integration with diverse storage backends beyond the local filesystem. Its usage became central to deploying stateful applications reliably within the Docker ecosystem.