Docker Concepts

Bind mounts

Connect a daemon-host file or directory to a container path without copying it into the image. A writable bind mount can alter host data. Default --mount requires an existing source; short -v may create a directory. Use only a fresh synthetic fixture, preferably read-only. Use a fresh private directory without symlinks, submounts or commas in its path. Recursive read-only behavior depends on the kernel.

Formal Syntax & Structure

docker syntaxdocker
--mount type=bind,src=HOST_PATH,dst=CONTAINER_PATH[,readonly]

Parameters & Attributes

NameTypeDescription
HOST_PATHstringExisting directory on the daemon host.
CONTAINER_PATHstringAbsolute destination inside the container.
readonlystringRestrict writes through this mount.

Working Example

Example Snippetdocker
docker run --rm --pull=never --network none --mount "type=bind,src=$lab,dst=/data,readonly" busybox:1.37 cat /data/note
Docker Reference