Docker Volumes
4 min read Quiz at the end
Persist container data with named volumes and bind mounts — understand the key differences.
Docker Volumes
# Named volume (Docker-managed)
docker volume create mydata
docker run -v mydata:/app/data myapp
# Bind mount (host path)
docker run -v $(pwd):/app node:20 npm test
# tmpfs (in-memory, not persisted)
docker run --tmpfs /tmp myapp
docker volume ls
docker volume inspect mydata
docker volume rm mydata
docker volume prune
Topic Quiz · 2 questions
Test your understanding before moving on
1. What is the key difference between a named volume and a bind mount?
💡 Named volumes are managed by Docker in /var/lib/docker/volumes; bind mounts point to exact host paths.
2. Which command removes all unused Docker volumes?
💡 docker volume prune removes all volumes not currently used by any container.