Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

docker volume Command

docker volume Command

Docker Command ReferenceDocker Command Reference


docker volume The command is used to manage Docker volumes. A volume is a filesystem used to persist data and can be shared and reused among containers. By using volumes, data is retained even when a container is stopped or deleted.

Common docker volume Command

  1. docker volume ls: List all volumes
  2. docker volume inspect: View detailed information about a volume
  3. docker volume create: Create a new volume
  4. docker volume rm: Delete one or more volumes
  5. docker volume prune: Remove unused volumes

docker volume ls Command

List all volumes.



docker volume ls

Output:



DRIVER              VOLUME NAME

local               my_volume

local               another_volume

docker volume inspect command

View detailed information about a specified volume.



docker volume inspect my_volume

Output:

[

    {

        "CreatedAt": "2024-07-23T00:00:00Z",

        "Driver": "local",

        "Labels": {},

        "Mountpoint": "/var/lib/docker/volumes/my_volume/_data",

        "Name": "my_volume",

        "Options": {},

        "Scope": "local"

    }

]

docker volume create command

Create a new volume.



docker volume create my_volume

Common parameters

Example:



docker volume create --name my_volume --label project=my_project

docker volume rm command

Delete one or more volumes.



docker volume rm my_volume

Delete multiple volumes:



docker volume rm volume1 volume2

docker volume prune command

Remove unused volumes.



docker volume prune

Use Cases

docker volume This command set provides powerful data management capabilities, allowing users to create, configure, and manage Docker volumes. By using these commands, users can achieve data persistence, sharing, and backup, meeting a variety of data management needs.


Docker Command ReferenceDocker Command Reference