Skip to content
BENIBIX Learn

Bind Mount

Infrastructure📦 ContainersContainer Storage and Networking

Also known as Docker Bind Mount, Host Mount, Host Folder Mount

A host folder shared straight into a container. Edits on either side show on both.

Think of it like

Think of it like a window between two rooms. What you change on one side shows on the other.

Example

Emma shares her project folder with a Node box. She saves a file in her editor, and the app inside picks up the change.

Why it matters

It ties a container to files you can see and edit. That makes it the usual choice while writing code.

Definition

A bind mount shares a folder from the host computer straight into a container. The container sees the folder at a path you choose. A change on either side shows up on the other at once. People use it to edit code on a laptop and run it in the container. Unlike a volume, the files live wherever the host keeps them.

Example code

bash
docker run -v "$PWD":/app -w /app node:22 node app.js
The folder Emma is in shows up inside the box at /app. The app runs from there.
The project folder on the host shows up inside the web container as /app. That link is a bind mount.

Common mistake

Using a bind mount for a database on a server. A volume is easier to back up and move, and it does not depend on one host's folders.

Key takeaways

  1. 1
    A host folder. Files stay where the host keeps them.
  2. 2
    Both ways. A change shows on both sides at once.
  3. 3
    For writing code. Volumes suit data on servers.

Compare