Where Should Database Data Live?
You run PostgreSQL in a container. You want the data to survive docker rm and container upgrades. What should you use?
docker rm
Choose one answer
A named volume mounted at the database's data directory (for example -v pgdata:/var/lib/postgresql/data).
-v pgdata:/var/lib/postgresql/data
Start it with --restart always, so Docker keeps the same container and its data.
--restart always
docker commit the container after every write so the data is saved in a new image.
docker commit
Nothing: the container's writable layer survives docker rm until the image is deleted.