🐳Docker Learning Hub
Lesson 13 • Bind mounts vs volumes
Lesson 13

Bind mounts vs volumes

This page explains the practical difference between using your real machine folder and using Docker-managed persistent storage.

Bind mount

Maps a real host file or folder path directly into the container.

Volume

Uses storage managed by Docker itself, which is often cleaner for persistent application data.

Rule of thumb

Bind mounts fit local code development. Volumes fit persistent service data like databases and uploads.

Bind mount example

docker run -v /Users/yash/project:/app my-image

The container reads your local project folder directly.

Volume example

docker run -v mydata:/app/data my-image

Docker manages mydata and keeps it separate from your host folder structure.

Choosing the right one

Use bind mounts for development
You want code changes on your host machine to appear immediately inside the container.
Use volumes for persistence
You want Docker-managed storage that survives container replacement more cleanly.
Be careful with bind mounts
A bind mount can hide files that were already present in the container path.

Next page: Lesson 14 explains multi-stage builds and why they help create smaller production-ready images.