List Volumes
Show all Docker volumes.
docker volume ls
Create Volume
Create a new volume.
docker volume create <volume-name>Create with driver options:
docker volume create --driver local --opt type=nfs my-volume
Inspect Volume
View detailed volume information.
docker volume inspect <volume-name>
Remove Volume
Delete a volume.
docker volume rm <volume-name>Remove all unused volumes:
docker volume prune
Mount Volume to Container
Run container with volume mount.
docker run -v <volume-name>:/path/in/container image-nameExample:
docker run -v my-data:/data nginx
Bind Mount
Mount host directory to container.
docker run -v /host/path:/container/path image-nameRead-only bind mount:
docker run -v /host/path:/container/path:ro image-name
Advertisement
Named vs Anonymous Volumes
Named volume:
docker run -v my-volume:/data nginxAnonymous volume:
docker run -v /data nginx
Mount Volume with --mount
Modern syntax for mounting volumes.
docker run --mount source=my-volume,target=/data nginxRead-only mount:
docker run --mount source=my-volume,target=/data,readonly nginx
Copy Data to Volume
Backup volume data.
docker run --rm -v my-volume:/source -v $(pwd):/backup ubuntu tar czf /backup/backup.tar.gz -C /source .
Restore Data to Volume
Restore from backup.
docker run --rm -v my-volume:/target -v $(pwd):/backup ubuntu tar xzf /backup/backup.tar.gz -C /target
Share Volume Between Containers
Multiple containers can use same volume.
docker run -v shared-data:/data container1
docker run -v shared-data:/data container2
Volume Drivers
Use third-party storage drivers.
docker volume create --driver local \
--opt type=nfs \
--opt o=addr=192.168.1.1,rw \
--opt device=:/path/to/dir \
nfs-volume
Last updated: January 2026