All jobs / DevOps / SRE / cloud / Containers

DevOps / SRE / cloud interview question · 0–1 years

In the team’s Docker Compose stack, Postgres loses all its data every time the container is recreated.

Why, and what is the fix?

The strongest answer

The data lives in the container’s writable layer, which goes away with the container; declare a named volume (or bind mount) on the data directory in the compose file so it outlives recreation

Why it works

Right — containers are disposable, volumes are where state lives. And remember `down -v` deletes named volumes too.

What a good answer covers

Answers that fall short

Who gets asked this

More Containers questions