Every time db is recreated, the database comes up empty — all the data is gone, even though there's a named volume pgdata specifically for persistence and it IS mounted into the container. The volume isn't full, the disk isn't full, and postgres starts fine. Figure out why the data isn't surviving and fix persistence.
db — postgres:15, Up, with the pgdata named volume mounted./var/lib/postgresql/data.$ docker inspect -f '{{range .Mounts}}{{.Source}} -> {{.Destination}}{{end}}' db
pgdata -> /data
$ docker logs db | tail -1
WARNING: /data is mounted but empty — is this the intended data directory?
You've solved it when:
/data)/var/lib/postgresql/data — so the
real data lands on the container's ephemeral layer and is lost on
recreate. The volume isn't broken; it's mounted in the wrong place.
db running with pgdata mounted at/var/lib/postgresql/data, so data now lives on the volume.
docker CLI only.db running with pgdata mounted at/var/lib/postgresql/data.
/data "work" (no error) yet lose data —VOLUME/PGDATA)?