Docker Volume Basics
Volumes are the preferred method of maintaining persistent data in Docker. In this lesson, we will begin learning how to use the volume subcommand to list, create, and remove volumes.
Step 1: List all Docker volume commands:
docker volume --help
create: Create a volume.
inspect: Display detailed information on one or more volumes.
ls: List volumes.
prune: Remove all unused local volumes.
rm: Remove one or more volumes.
Step 2: List all volumes on a host:
docker volume ls
Step 3: Create two new volumes:
docker volume create test-volume1
docker volume create test-volume2
Step 4: Get the flags available when creating a volume:
docker volume create -h
Step 5: Inspecting a volume:
docker volume inspect test-volume1
Step 6: Deleting a volume:
docker volume rm test-volume1
Removing all unused volumes:
docker volume prune
Last updated