Difficulty: Intermediate
Compare Docker Volumes and Bind Mounts.
- **Volumes**: Managed by Docker in a specific part of the host filesystem (`/var/lib/docker/volumes`). Recommended for production because they are isolated from host OS specifics. - **Bind Mounts**: A directory or file on the host machine is mounted into a container. They depend on the host's directory structure and are great for local development (e.g., hot-reloading code).
# Volume (recommended)
docker run -v my-vol:/app nginx
# Bind Mount (dev only)
docker run -v $(pwd):/app nginx
Volumes are abstract and managed; Bind Mounts are direct links to host files.
Persistence, Storage, Mounting