How to List Volumes in Docker: Commands and Examples
Use the
docker volume ls command to list all Docker volumes on your system. This command shows volume names and drivers, helping you manage storage used by containers.Syntax
The basic command to list Docker volumes is docker volume ls. You can add options like -q to show only volume names or --filter to narrow down the list.
docker volume ls: Lists all volumes with details.-q: Shows only volume names.--filter: Filters volumes by criteria like dangling or name.
bash
docker volume ls docker volume ls -q docker volume ls --filter dangling=true
Example
This example shows how to list all Docker volumes and then list only their names.
bash
docker volume ls docker volume ls -q
Output
DRIVER VOLUME NAME
overlay my_volume_1
local my_volume_2
my_volume_1
my_volume_2
Common Pitfalls
Sometimes users expect docker volume ls to show detailed information like size or mount points, but it only lists volume names and drivers. To see more details, use docker volume inspect <volume_name>.
Another common mistake is confusing volumes with bind mounts; volumes are managed by Docker and listed with this command, while bind mounts are host directories linked to containers and not listed here.
bash
docker volume ls # Correct: lists volumes docker volume ls -l # Wrong: -l is not a valid option and will cause an error # To see details use: docker volume inspect my_volume_1
Quick Reference
Here is a quick cheat sheet for listing Docker volumes:
| Command | Description |
|---|---|
| docker volume ls | List all Docker volumes with driver and name |
| docker volume ls -q | List only volume names |
| docker volume ls --filter dangling=true | List volumes not used by any container |
| docker volume inspect | Show detailed info about a specific volume |
Key Takeaways
Use
docker volume ls to see all Docker volumes on your system.Add
-q to list only volume names for simpler output.Use
docker volume inspect to get detailed information about a volume.Remember volumes are different from bind mounts and only volumes appear in this list.
Avoid invalid options like
-l which cause errors.