Skip to main content

Volumes, Bind Mounts, and Data Lifecycle

Container filesystems are ephemeral -- when you remove a container, everything inside it is deleted. If you are running a database, uploading files, or storing any data that matters, you must mount external storage. This module covers how.

Golden Rule

If you run a database without a volume, your data will be deleted when the container is removed.

How Storage Works in Docker

What You Will Learn

LessonWhat It Covers
Volumes vs Bind MountsWhen to use each storage type, with practical examples
Backup and RestorePortable patterns for backing up and migrating volume data

Quick Decision Guide

QuestionAnswer
Is it a database or persistent app state?Use a named volume
Is it source code during development?Use a bind mount
Is it temporary data (cache, sessions)?Use tmpfs
Is it a config file injected from the host?Use a bind mount (read-only)

Prerequisites

  • Understand containers and docker run (Module 4)
  • Understand Docker networking basics (Module 5)