Docker Course
Docker
/
Beginner

Persistent Storage

Definition

The concept of saving data generated by a container so that it survives even if the container crashes, is deleted, or is recreated.

Explain Like I'm New

Containers have amnesia. If you delete a container, every file inside it is instantly vaporized. Persistent storage is plugging an external hard drive into the container. When the container dies, the hard drive (and the data) survives.

Real World Example

Running a MySQL database. If you don't use persistent storage, the moment you restart the MySQL container, all your users and passwords are deleted. By mounting a persistent volume, the database files are safely kept outside the container's volatile memory.

Common Use Cases

  • •Databases
  • •User uploads
  • •Log files

Interview Questions

basic

  • By default, are files created inside a Docker container permanent or temporary?

intermediate

  • Why does writing data directly into a container's writable layer severely impact performance?

Flash Cards

Question

Permanent or temporary?

Click to reveal answer
Answer

Temporary. They are completely tied to the lifecycle of the container and disappear when the container is removed.

Question

Why impact performance?

Click to reveal answer
Answer

Because the container's internal writable layer relies on the Union File System (storage driver), which is extremely slow at processing heavy read/write loads (like a database). Volumes bypass this system and write directly to the host OS at native speeds.