Member-only story

Bind Mount

Meghasharmaa
4 min readMar 12, 2024

Bind mounts in Docker allow you to mount a file or directory on the host machine into a container. This means that changes made to the files in the mounted directory within the container will be reflected on the host, and vice versa. Bind mounts are commonly used for development, debugging, or providing configuration files to containers.

Bind mounts have been around since the early days of Docker. Bind mounts have limited functionality compared to volumes. When you use a bind mount, a file or directory on the host machine is mounted into a container. The file or directory is referenced by its absolute path on the host machine. By contrast, when you use a volume, a new directory is created within Docker’s storage directory on the host machine, and Docker manages that directory’s contents.

The file or directory does not need to exist on the Docker host already. It is created on demand if it does not yet exist. Bind mounts are very performant, but they rely on the host machine’s filesystem having a specific directory structure available. If you are developing new Docker applications, consider using named volume instead. You can’t use Docker CLI commands to directly manage bind mounts.

👉 Choose the — mount flag

--mount: Consists of multiple key-value pairs, separated by commas and each consisting of a <key>=<value> tuple. The --mount

--

--

Meghasharmaa
Meghasharmaa

Written by Meghasharmaa

DevOps Architect | AWS | Docker | Kubernetes | Terraform | Google Cloud | Python

No responses yet