← Docker learning path
Docker · Module 5 of 10

Volumes and data

Data inside a container is lost when it is removed; volumes keep it safe.

📖 Key ideas

  1. A container's writable layer disappears when the container is removed.
  2. Volumes store data outside the container and survive restarts and removal.
  3. -v dbdata:/var/lib/mysql mounts a named volume.
  4. Bind mounts map a host folder: -v ./site:/usr/share/nginx/html.
  5. Back up volumes; they hold your real data.
💡 Real-life example: A container is a hotel room; a volume is your locker that keeps your things when you check out.
VolumeDocker-managed storage that survives containers
Bind mountA host folder mapped into a container
Writable layerTemporary changes inside a container
-vFlag that attaches storage