Named Volumes

Named Volumes and Where Docker Stores Them

A named volume is a directory that Docker 514 creates, owns and mounts wherever you ask. It exists independently of any container, so it survives docker rm, and the same volume can be mounted into a replacement container:

Creating and inspecting a named volumeShell
docker volume create l3-pgdata
docker volume inspect l3-pgdata --format '{{.Driver}} {{.Mountpoint}}'
sudo ls -ld /var/lib/docker/volumes/l3-pgdata/_data
Output
l3-pgdata
local /var/lib/docker/volumes/l3-pgdata/_data
drwxr-xr-x 2 root root 4096 Sep 25 18:38 /var/lib/docker/volumes/l3-pgdata/_data

The local driver keeps each volume in /var/lib/docker/volumes/<name>/_data, readable only by root; treat that path as Docker's private property and reach the data through containers. On Docker Desktop 514 it lives inside the desktop VM, not on the Mac or Windows disk at all. Mount a volume with -v l3-pgdata:/path or the more explicit --mount type=volume,src=l3-pgdata,dst=/path. If the volume does not exist yet, docker run creates it; if it is empty, Docker first copies in whatever the image has at the mount path, so a fresh volume starts with the image's files. An image can also declare VOLUME /path in its Dockerfile: then every container gets an anonymous volume there, named by a random hash, which is why Container Lifecycle removed PostgreSQL 1,289 containers with docker rm -v.