Docker Volumes
Persist data with named volumes and bind mounts done right.
- docker volume
- bind mount
- persist data
- postgres docker
- volume inspect
Docker Volumes
Persist data with named volumes and bind mounts done right.
Commands
| Command | What it does |
|---|---|
docker volume create pgdata | Create a named volume |
docker volume ls | List volumes |
docker run -v pgdata:/var/lib/postgresql/data postgres:16 | Attach a volume |
docker run -v $(pwd):/app -w /app node:22 npm run dev | Bind-mount source for live dev |
docker volume inspect pgdata | See where data lives on the host |
Example
docker volume create pgdata
docker run -d --name pg -v pgdata:/var/lib/postgresql/data -e POSTGRES_PASSWORD=secret postgres:16
FAQ
Named volume vs bind mount?
Named volumes are portable and managed by Docker (best for databases); bind mounts mirror host source (best for dev).
Where is volume data on disk?
Under /var/lib/docker/volumes on Linux โ inspect it, but back it up via containers, not raw paths.
FAQ
Named volume vs bind mount?
Named volumes are portable and managed by Docker (best for databases); bind mounts mirror host source (best for dev).
Where is volume data on disk?
Under /var/lib/docker/volumes on Linux โ inspect it, but back it up via containers, not raw paths.
Docker
Docker Install and Setup
Verify the Docker engine, configure context, and check versions.
Docker Images
Pull, list, tag, inspect, and remove images confidently.
Docker Containers
Run, list, stop, and clean up containers in daily work.
Docker Run Options
The flags that matter: detach, ports, env, volumes, limits.