Skip to content

Commit 1df2ac0

Browse files
committed
update bind-mount docs
Signed-off-by: Akihiro Suda <[email protected]>
1 parent 36a2f3e commit 1df2ac0

2 files changed

Lines changed: 38 additions & 5 deletions

File tree

docs/reference/commandline/service_create.md

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,16 +363,34 @@ volumes in a service:
363363
<td></td>
364364
<td>
365365
<p>The Engine mounts binds and volumes <tt>read-write</tt> unless <tt>readonly</tt> option
366-
is given when mounting the bind or volume.
366+
is given when mounting the bind or volume. Note that setting <tt>readonly</tt> for a
367+
bind-mount does not make its submounts <tt>readonly</tt>. See also <tt>bind-nonrecursive</tt>.
367368
<ul>
368369
<li><tt>true</tt> or <tt>1</tt> or no value: Mounts the bind or volume read-only.</li>
369370
<li><tt>false</tt> or <tt>0</tt>: Mounts the bind or volume read-write.</li>
370371
</ul></p>
371372
</td>
372373
</tr>
374+
</table>
375+
376+
#### Options for Bind Mounts
377+
378+
The following options can only be used for bind mounts (`type=bind`):
379+
380+
381+
<table>
382+
<tr>
383+
<th>Option</th>
384+
<th>Description</th>
385+
</tr>
386+
<tr>
387+
<td><b>bind-propagation</b></td>
388+
<td>
389+
<p>See the description below.</p>
390+
</td>
391+
</tr>
373392
<tr>
374393
<td><b>consistency</b></td>
375-
<td></td>
376394
<td>
377395
<p>The consistency requirements for the mount; one of
378396
<ul>
@@ -384,9 +402,23 @@ volumes in a service:
384402
</p>
385403
</td>
386404
</tr>
387-
</table>
405+
<tr>
406+
<td><b>bind-nonrecursive</b></td>
407+
<td>
408+
By default, submounts are recursively bind-mounted as well. However, this behavior can be confusing when a
409+
bind mount is configured with <tt>readonly</tt> option, because submounts are not mounted as read-only.
410+
Set <tt>bind-nonrecursive</tt> to disable recursive bind-mount.<br />
411+
412+
A value is optional:
388413

389-
#### Bind Propagation
414+
<ul>
415+
<li><tt>true</tt> or <tt>1</tt>: Disables recursive bind-mount.</li>
416+
<li><tt>false</tt> or <tt>0</tt>: Default if you do not provide a value. Enables recursive bind-mount.</li>
417+
</ul>
418+
419+
</td>
420+
</tr>
421+
</table>
390422

391423
Bind propagation refers to whether or not mounts created within a given
392424
bind mount or named volume can be propagated to replicas of that mount. Consider

man/docker-run.1.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,12 +446,13 @@ according to RFC4862.
446446

447447
* `src`, `source`: mount source spec for `bind` and `volume`. Mandatory for `bind`.
448448
* `dst`, `destination`, `target`: mount destination spec.
449-
* `ro`, `read-only`: `true` or `false` (default).
449+
* `ro`, `readonly`: `true` or `false` (default). Note that setting `readonly` for a bind mount does not make its submounts read-only. See also `bind-onrecursive`.
450450

451451
Options specific to `bind`:
452452

453453
* `bind-propagation`: `shared`, `slave`, `private`, `rshared`, `rslave`, or `rprivate`(default). See also `mount(2)`.
454454
* `consistency`: `consistent`(default), `cached`, or `delegated`. Currently, only effective for Docker for Mac.
455+
* `bind-nonrecursive`: `true` or `false` (default). If set to `true`, submounts are not recursively bind-mounted. This option is useful for `readonly` bind mount.
455456

456457
Options specific to `volume`:
457458

0 commit comments

Comments
 (0)