Creating and Managing Volumes
You'll learn the practical commands to create, list, inspect, and remove Docker volumes in your development workflow.
What Are Volume Management Commands?
Now that you understand Docker volumes conceptually, you need to know how to actually work with them. Docker provides a straightforward CLI (docker volume) to handle the complete lifecycle of volumes—from creation through cleanup.
Core Volume Operations
Think of volume management like managing external hard drives: you can create them, see what's available, examine their details, and remove them when they're no longer needed.
Create a volume:
docker volume create my-data
This creates a named volume managed by Docker. Without a name, Docker generates one automatically when you first use it.
List all volumes:
docker volume ls
Shows every volume on your system, helping you track what storage exists.
Inspect a volume:
docker volume inspect my-data
Returns JSON details including the mount point, driver, and creation date—useful for troubleshooting.
Remove a volume:
docker volume rm my-data
Deletes the volume permanently. Note: you cannot remove volumes currently in use by a container.
Remove unused volumes:
docker volume prune
Cleans up all volumes not attached to any container—essential for preventing storage bloat over time.
Volumes Persist Independently
Volumes exist outside container lifecycles. You can create a volume, attach it to multiple containers over time, and the data persists even after all containers are removed. Only explicit removal (rm or prune) deletes the data.
Key Takeaway: The docker volume command suite provides complete control over volume creation, inspection, and cleanup—enabling persistent data management independent of container lifecycles.