A container's filesystem is ephemeral: anything written to it lives only as long as the container, and is lost when the container is removed. That is fine for stateless applications, but databases, uploaded files, and anything that must survive a container's lifecycle need persistent storage. Docker volumes (and bind mounts) provide it, decoupling data from the container so it persists independently.
Docker offers a few mechanisms. Named volumes are storage managed by Docker, the preferred way to persist application data. Bind mounts map a host directory into a container, useful in development to share source code. tmpfs mounts store data in memory only. Understanding when to use each — and why volumes are preferred for persistent data — is essential for stateful containers.
This lesson covers why container filesystems are ephemeral, named volumes versus bind mounts versus tmpfs, the syntax for mounting them, common use cases like database persistence, and the volume lifecycle. With volumes, containers can be freely stopped, removed, and recreated while their important data lives on.