Skip to main content

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

VolumeBind mount
Managed by DockerSimply mounts a host folder
Stored in /var/lib/docker/volumes/...Stored wherever you specify
Convenient for productionConvenient for development
Docker controls the dataFull 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 ready
Premium

A concise answer to help you respond confidently on this topic during an interview.