Networking & VolumesBeginner
1Question 1 of 1
bashWhat is the difference between Bind Mounts and Named Volumes in Docker?
Explanation & Concept
• Named Volumes: Managed entirely by Docker inside `/var/lib/docker/volumes/`. Isolated from host OS quirks, backed up easily, and recommended for production databases. • Bind Mounts: Directly mounts a specific directory or file from the host machine into the container (`./src:/app/src`). Ideal for local development with live hot-reloading.
Code Example
bash
# 1. Named volume for database data
docker run -v db_storage:/var/lib/postgresql/data postgres:16
# 2. Bind mount for local development hot-reload
docker run -v $(pwd)/src:/app/src -p 3000:3000 my-node-appHow It Works & Key Takeaways
Bind mounts reflect host file changes immediately inside the container, whereas named volumes survive container destruction and system restarts.
Mock Test · 1 Questions · Optional
Ready for Dockerfile Best Practices?
Take a quick test to evaluate yourself, or move straight to the next module.
Beginner1 questions