- Storage drivers manage image and container filesystem layers (for example
overlay2,aufs). - Volume drivers (or volume plugins) provide persistent storage for containers and let Docker provision volumes on the host or external storage providers.
Key differences: Storage drivers vs Volume drivers
Default volume driver
The default volume driver islocal. Volumes created with the local driver store their data on the Docker host, typically under:
/var/lib/docker/volumes
Using driver-backed volumes
You can use a driver-backed volume by either creating the volume first and then attaching it to a container, or by creating and attaching the volume inline when running the container.- Create a volume explicitly, then run the container:
- Create and attach the volume inline with
--mount(specifying the volume driver):
ebs-vol volume remains intact in the external storage (for example, on AWS EBS) and can be reused by other containers.
Volume plugins must be installed and configured on the Docker host (and often require cloud credentials or proper IAM permissions). Install and enable the plugin before attempting to create or mount driver-backed volumes.
Useful commands
Run these commands to inspect plugins and volumes on your host:Driver names and configuration details vary by plugin. Always consult the plugin’s documentation for the exact driver string, required configuration, and any provider-specific setup steps (credentials, region, IAM roles, etc.).
Best practices and troubleshooting
- Install and validate the plugin on each Docker host that will create or attach volumes from that provider.
- Verify required credentials/permissions (for example, IAM roles for AWS EBS) before provisioning volumes.
- Use explicit volume creation when you need predictable names, lifecycle, or to pre-provision storage.
- Use inline
--mountcreation for convenience when you want Docker to create the volume automatically with the specified driver. - If you see mount or permission errors, check the plugin logs and the provider’s access controls.
Summary
- Storage drivers manage container/image layering; volume drivers manage persistent volumes.
- The default
localdriver stores data on the host under/var/lib/docker/volumes. - Third-party volume plugins let you provision persistent storage on cloud and external platforms — install and configure them first.
- Use
docker volume createor the--mountflag to create and attach driver-backed volumes to containers.