By default, Docker containers are temporary. If a container is deleted — all its data is gone. This is dangerous for databases and real applications.
A Docker volume is a storage location managed by Docker outside the container lifecycle.
docker volume create mydata
docker volume ls
docker run -d \
-v mydata:/data \
--name test-container \
nginx
Now anything stored in /data
will survive container deletion.
Bind mounts directly map a host folder. Useful during development.
docker run -d \
-v $(pwd):/app \
--name dev-container \
node
docker volume inspect mydata
Volumes are a **must** for databases, backend apps, and production workloads.
Next: Docker Networking →