Docker & Containers (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)
What are Docker Volumes, Bind Mounts, and tmpfs mounts? How do they differ?
junior LevelMost AskedDocker & Containers
In Simple Words: Containers have ephemeral writable filesystems; when a container is deleted, its data is permanently lost. Docker provides three persistent storage mechanisms:
- Named Volumes (
docker run -v my_data:/data): Managed entirely by Docker inside the host's/var/lib/docker/volumes/directory. Isolated from host OS interference, easy to back up, and the best choice for databases. - Bind Mounts (
docker run -v /host/path:/container/path): Mounts an arbitrary file or folder from the host filesystem directly into the container. Excellent for local development (live code reload), but introduces dependencies on host OS directory structures. - tmpfs Mounts (
docker run --tmpfs /app/cache): Stored entirely in the host system's RAM. Never written to disk; ideal for sensitive in-memory secrets or temporary caches.