What is a bind mount?
A bind mount is a way to attach a specific folder from the host machine inside a container, so the container works directly with your real files instead of the data inside Docker volumes.
In other words, a bind mount rigidly ties a host path to a path inside the container.
Example
bash
docker run -v /home/user/project:/app nginx/home/user/project- the real directory on the host/app- the path inside the container
Now everything that changes on the host is immediately visible in the container, and vice versa.
How it differs from a volume
| Volume | Bind mount |
|---|---|
| Managed by Docker | Simply mounts a host folder |
Stored in /var/lib/docker/volumes/... | Stored wherever you specify |
| Convenient for production | Convenient for development |
| Docker controls the data | Full OS access to the data |
When a bind mount is used
- local development, so that code changes immediately reach the container
- sharing configs or logs, when you need to view them directly on the host
Summary: a bind mount is a direct connection of a host folder to a container. It is convenient for development and gives instant synchronization, but it is less secure and less manageable than a volume.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.