Skip to main content
In this tutorial, you’ll learn how to inspect, remove, prune, and configure Docker volumes. Managing volumes effectively helps persist data across container lifecycles and keeps your host system clean.

Table of Contents


Inspecting a Volume

Use docker volume inspect to retrieve metadata about your volume, including driver, mount point, labels, and scope:
Sample output:
This command is essential for troubleshooting mount permissions and verifying where Docker stores your volume data on the host.

Removing a Volume

To delete a volume that’s no longer used by any container:
If the volume is active, Docker returns an error:
Stop or remove the container first, then run the same command again:

Pruning Unused Volumes

Clean up all dangling volumes in one step to free up disk space:
You’ll see a confirmation prompt:
Pruning removes all unused volumes. Ensure you have backups of any critical data before proceeding.

Verifying Mount Options

By default, volumes are mounted read-write. To inspect a container’s mount configuration:
Look for the Mounts section:
The "RW": true field confirms the volume is mounted read-write inside the container.

Mounting a Volume as Read-Only

To ensure data integrity, you can mount a volume as read-only. Use the --mount flag with readonly:
This is useful for scenarios where containers should not modify shared data.

Common Docker Volume Commands


References

Watch Video