Interview Prep/Docker/Storage, volumes and disk space

Data is not persisted: after container recreate the database is empty.

IntermediateTroubleshootingStorage, volumes and disk space
Answer

Likely causes → Wrong mount path, anonymous volume created (image's VOLUME) so a new one appears each time, or Compose project name changed so the volume name differs.

Diagnose →

docker inspect -f '{{json .Mounts}}' db
docker volume ls

Fix → Mount a named volume at the exact data directory, reuse the same project/volume name (name: in compose volume).

Prevent → Explicit named volumes with fixed name:.

All Docker questions Roadmap: Docker & containers

More on Storage, volumes and disk space