beginnerStorage: Volumes, Bind Mounts & tmpfs

Postgres data vanished after a routine container image upgrade

A team upgraded their postgres:15 container to postgres:16 by stopping the old container, removing it, and starting a new one — all data was lost. Diagnose. Expected reasoning: the original container was likely run with no persistent storage at all (writable layer only), so docker rm destroyed the writable layer along with all data. Fix going forward: always run stateful services with an explicitly named volume (--mount type=volume,src=pgdata,...) so container replacement is decoupled from data lifecycle; verify with docker volume ls before any docker rm.

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

Continue to Live reload isn't picking up file changes inside a containerized dev environment← Back to all Docker questions