Lesson 3.1

Volumes and persistent data

Anything written to the container filesystem dies with the container.

10mBeginner19.3k students

Overview

Containers are disposable, data is not

Anything written to the container filesystem dies with the container. A named volume is managed storage that outlives it, which is what makes running a database in a container reasonable.

Bind mounts map a host directory in and are the right tool for development, where you want your source to appear live inside the container. They are a poor fit for production, since they couple the container to the host layout.

A volume is not a backup. It is on one machine and it is one accidental prune away from being gone.

In this lesson you will:

  • Choose between a volume and a bind mount
  • Keep database data across restarts
  • Back up and restore a volume

Resources

Previous Lesson
Next Lesson
Volumes and persistent data — Docker Essentials — Vertex