liveBook · Manning

Volume

As explained in Just Use Postgres!

A Docker volume is persistent host-managed storage mounted into containers independently of their writable container filesystems.

A Docker volume provides host-managed persistence for container data. Mounting postgres-volume at /var/lib/postgresql/data keeps PostgreSQL files available after stopping, removing, or recreating the container. section 1.3

Persist PostgreSQL data

Create and mount a volume with: docker volume create postgres-volume, then docker run --name postgres -v postgres-volume:/var/lib/postgresql/data -d postgres:17.2. The container runs PostgreSQL in the background while Docker stores its database files on the host. section 1.3

Listing 1.1 Starting a Postgres container on Unix
docker volume create postgres-volume

docker run --name postgres \
    -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=password \
    -p 5432:5432 \
    -v postgres-volume:/var/lib/postgresql/data \
    -d postgres:17.2

Use the Unix command listing to create postgres-volume and mount it into the PostgreSQL data directory. section 1.3

How Just Use Postgres! covers it

How deep it goes
Explains creation, mounting, host persistence, and a runnable command, while deferring production security and administration.
Examples
Uses postgres-volume mounted at /var/lib/postgresql/data in a PostgreSQL 17.2 container.
What it assumes
Assumes Docker is installed and teaches volume creation and mounting through PostgreSQL container setup.
What you can do after
Operate Docker storage by creating a named volume and mounting it into a PostgreSQL container.
How it connects
Connects Docker volumes with containers, PostgreSQL, Docker Hub images, and host-port mapping.

Also explained in

Compare how 8 books explain volume →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Just Use Postgres!. The section links point to the parts of the book it draws on.