Docker List Volumes

In this guide, we will see how to list Docker volumes with examples.

The Importance of Listing Volumes

Inventory Management: Keep track of your volumes and their purposes. 

Data Management: Understand where your containerized applications are storing their persistent data.

Resource Optimization: Identify unused volumes that might be occupying crucial disk space. 

Listing All Docker Volumes

Basic Volume Listing: 

The simplest command to fetch a list of all your Docker volumes is:

docker volume ls

For example:

$ docker volume ls
DRIVER              VOLUME NAME
local               projectA_data
local               projectB_backup
local               nginx_config

The above output showcases three volumes (projectA_data, projectB_backup, and nginx_config) all using the default local driver.

Filtering Volume Listings: 

Docker provides capabilities to filter volume listings based on specific criteria. This feature is handy when dealing with a large number of volumes. 

To list volumes created with a specific driver:

docker volume ls -f driver=DRIVER_NAME

For example:

$ docker volume ls -f driver=local
DRIVER              VOLUME NAME
local               projectA_data
local               projectB_backup
local               nginx_config

Inspecting Volumes: 

For a more in-depth view of a particular volume:

$ docker volume inspect projectA_data
[
    {
        "CreatedAt": "2023-08-15T09:30:25Z",
        "Driver": "local",
        "Labels": {},
        "Mountpoint": "/var/lib/docker/volumes/projectA_data/_data",
        "Name": "projectA_data",
        "Options": {},
        "Scope": "local"
    }
]

This detailed view provides insights such as creation date, mount point on the host system, and other associated metadata.

Conclusion

In this guide, we have seen how to list docker volumes, how to filter docker volumes, and how to inspect the docker volume.

Comments