1. What Is a Volume in Docker?

A volume is a Docker-managed persistent storage mechanism.

It is:

Core idea:

A container is temporary.

A volume is durable.


2. The Problem Volumes Solve

By default, container storage is ephemeral.

When you run:

docker run mongo

MongoDB writes data inside the container’s writable layer.

If you remove the container:

docker rm -f <container_id>

All data is lost.