Skip to content

Commit

Permalink
engine: add recursive bind mounts
Browse files Browse the repository at this point in the history
Signed-off-by: David Karlsson <[email protected]>
  • Loading branch information
dvdksn committed Nov 16, 2023
1 parent 4e3143d commit 53d7ffd
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion content/storage/bind-mounts.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,39 @@ $ docker container stop devtest
$ docker container rm devtest
```

## Recursive mounts

When you bind mount a path that itself contains mounts, those submounts are
also included in the bind mount by default. This behavior is configurable,
using the `bind-recursive` option for `--mount`.

If the bind mount is read-only, the Docker Engine makes a best-effort attempt
at making the submounts read-only as well. This is referred to as recursive
read-only mounts. Recursive read-only mounts require Linux kernel version 5.12
or later. If you're running an older kernel version, submounts are
automatically mounted as read-write by default. Attempting to set submounts to
be read-only on a kernel version earlier than 5.12, using the
`bind-recursive=readonly` option, results in an error.

Supported values for the `bind-recursive` option are:

`bind-recursive=<enabled|true|1>` (default)
: Enables recursive bind-mount.
Read-only mounts are made recursively read-only if kernel is v5.12 or later.
Otherwise, submounts are read-write.

`bind-recursive=<disabled|false|0>`
: Disables recursive bind-mounts.
Submounts are ignored (not included in the bind mount).

`bind-recursive=writable`
: Enables recursive bind-mounts.
Submounts are read-write.

`bind-recursive=readonly`
: Enables recursive bind-mounts.
Submounts are read-only.

## Configure bind propagation

Bind propagation defaults to `rprivate` for both bind mounts and volumes. It is
Expand Down Expand Up @@ -396,4 +429,4 @@ and

- Learn about [volumes](volumes.md).
- Learn about [tmpfs mounts](tmpfs.md).
- Learn about [storage drivers](/storage/storagedriver/).
- Learn about [storage drivers](/storage/storagedriver/).

0 comments on commit 53d7ffd

Please sign in to comment.