Process Flow - Creating and managing volumes
Start
Create Volume
List Volumes
Use Volume in Container
Inspect Volume
Remove Volume
End
This flow shows how to create a volume, list it, use it in a container, inspect details, and finally remove it.
docker volume create myvol docker volume ls docker run -d -v myvol:/data busybox sleep 3600 docker volume inspect myvol docker volume rm myvol
| Step | Command | Action | Result/Output |
|---|---|---|---|
| 1 | docker volume create myvol | Create a new volume named 'myvol' | myvol |
| 2 | docker volume ls | List all volumes | DRIVER VOLUME NAME local myvol |
| 3 | docker run -d -v myvol:/data busybox sleep 3600 | Run container with volume mounted at /data | Container ID returned, container running in background |
| 4 | docker volume inspect myvol | Show details of volume 'myvol' | [{"Name":"myvol","Driver":"local","Mountpoint":"/var/lib/docker/volumes/myvol/_data"}] |
| 5 | docker volume rm myvol | Remove volume 'myvol' | Error: volume is in use by container (if container running) OR 'myvol' removed successfully if container stopped |
| 6 | docker rm -f <container_id> | Stop and remove container to free volume | Container removed |
| 7 | docker volume rm myvol | Remove volume 'myvol' after container removal | myvol |
| Variable | Start | After Step 1 | After Step 3 | After Step 5 | After Step 7 |
|---|---|---|---|---|---|
| Volumes | [] | ["myvol"] | ["myvol"] | ["myvol"] or error if container running | [] |
| Containers | [] | [] | [container running] | [container running] | [] |
docker volume create <name> # Create a volume docker volume ls # List volumes docker run -v <vol>:/path # Use volume in container docker volume inspect <name> # Show volume details docker volume rm <name> # Remove volume (only if not in use)