Docker Volumes

LEVEL 0

The Problem

You need to run a PostgreSQL database in a container. The data must persist even if the container is recreated.

You could use bind mounts (map a host directory), but that has issues:

  • Host filesystem permissions can conflict
  • Not portable across different hosts
  • Harder to backup and migrate
  • Host directory structure leaks into container world

You want Docker to manage the storage for you. You want a solution that lets Docker manage the details.

This is what Docker volumes provide.