advancedTop 100 Interview Questions
How would you persist PostgreSQL data across container recreation in Compose?
Mount a named volume to the container's data directory (`/var/lib/postgresql/data`) via the service's `volumes:` key and declare that volume in the top-level `volumes:` section — recreating the container (e.g., on image update) then reuses the same underlying data.
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