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
| Name | Type | Description |
|---|---|---|
| HOST_PATH | string | Existing directory on the daemon host. |
| CONTAINER_PATH | string | Absolute destination inside the container. |
| readonly | string | Restrict 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