A is storage that Docker manages outside every container's writable layer. Removing a container does not touch its volumes.
container "writer" container "reader"
/reports ──────┐ ┌────── /data
▼ ▼
volume "reports" (one directory on the host)
/var/lib/docker/volumes/reports/_dataThe volume commands
| Command | Does |
|---|---|
docker volume create NAME | Create an empty volume |
docker volume ls | List volumes |
docker volume inspect NAME | Show driver, labels and mountpoint |
docker volume rm NAME | Remove a volume that no container uses |
docker volume prune | Remove unused anonymous volumes (-a for named too) |
docker volume create reports
docker volume ls
docker volume inspect reportsDRIVER VOLUME NAME
local reports
[
{
"CreatedAt": "2026-10-11T20:44:07Z",
"Driver": "local",
"Labels": null,
"Mountpoint": "/var/lib/docker/volumes/reports/_data",
"Name": "reports",
"Options": null,
"Scope": "local"
}
]Mountpoint is the real directory on the host. Print only that field with --format:
docker volume inspect --format '{{.Mountpoint}}' reportsMount a volume with -v
-v NAME:PATH mounts the volume NAME at PATH inside the container. Anything written under PATH goes into the volume.
docker run --name writer -v reports:/reports alpine:3.20 sh -c 'echo ok > /reports/daily.txt'
docker run -d --name reader -v reports:/data alpine:3.20 sleep infinity
docker exec reader cat /data/daily.txtokwriter has exited, but its file is in the volume. reader mounts the same volume at a different path and reads it. Several containers can mount one volume at the same time.
Look at the data from the host
/var/lib/docker belongs to root. Use sudo:
sudo ls -l /var/lib/docker/volumes/reports/_datatotal 4
-rw-r--r-- 1 root root 3 Oct 11 20:44 daily.txtFiles written by a process running as root in the container are owned by root on the host.
Remove volumes
A volume cannot be removed while any container, running or exited, refers to it:
$ docker volume rm reports
Error response from daemon: remove reports: volume is in use - [e1dd94dc29ef…, 99fddfcd7640…]Remove the containers first, then the volume. docker volume rm deletes the data for good.
Named and anonymous volumes
| Named volume | Anonymous volume | |
|---|---|---|
| Created by | docker volume create or -v name:/path | -v /path with no name, or an image VOLUME |
| Name | Yours, e.g. reports | A 64-character hash |
| Easy to reattach | Yes, by name | Only by copying the hash |
docker rm -v | Kept | Removed |
docker volume prune | Kept unless -a | Removed when unused |
Use named volumes for anything you want to keep.