liveBook · Manning

Bind mount

As explained in Learn Docker in a Month of Lunches, Second Edition

A local bind mount makes a directory or file from the host filesystem available at a path in a container.

A bind mount makes a directory on the host available at a path inside a container. The container sees an ordinary directory, while files can be accessed from both environments. section 6.3

Use bind mounts when host-controlled files need to participate in container workflows:

  • Share application data with a host filesystem, including local disks, RAID arrays, or accessible network storage. section 6.3
  • Load local source code into a container so edits appear immediately without rebuilding the image. section 6.5
  • Load configuration files as read-only mounts when the container should consume but not modify host data. section 6.3 section 6.5

Mount a host database directory

Create a local databases directory, mount it at /data, start the to-do application, call it with curl, and list the host directory. The generated database files appear on the host. Use Windows-style source and target paths for Windows Server containers. section 6.3

A directory mount replaces the target directory’s image contents rather than merging with them. Single-file mounts merge with an existing target directory on Linux, but Windows Server containers do not support that behavior. Network-backed storage may also lack local-disk performance or full filesystem features. section 6.4 section 6.5

How Learn Docker in a Month of Lunches, Second Edition covers it

How deep it goes
Explains mounting, bidirectional access, read-only use, directory shadowing, file behavior, and storage limitations across operating systems.
Examples
Demonstrates host database persistence, local source-code loading, read-only configuration, and directory-versus-file mount behavior.
What it assumes
Assumes basic Docker container commands and host filesystem paths while teaching mount targets, source paths, and platform variations.
What you can do after
Operate/configure Docker containers with host-backed directories, verify mounted data, and choose read-only or writable access appropriately.
How it connects
Connects bind mounts with Docker volumes, container filesystems, image layers, persistent storage, configuration files, and least privilege.

Also explained in

Compare how 2 books explain bind mount →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Docker in a Month of Lunches, Second Edition. The section links point to the parts of the book it draws on.