Skip to content

Commit 05b3277

Browse files
committed
config: Document 'recursive' and 'bind' mount options extensions
They are not filesystem types, so they don't belong in 'type'. The specs claim mount(2) as inspiration for this modeling (which makes sense, since that's the syscall Linux runtimes will make to implement it), and there (recursive) bind is represented by mountflags (MS_REC | MS_BIND). Currently the 'options' property handles both mount(2)'s mountflags and data, so 'options' is a good spot for these two settings. We may eventually add entries for other mount(8) command-line options (e.g. --move, --make-shared, ...), but I've left those off until someone pitches a motivational use case for them. The example I'm touching used: "type": "bind", ... "options": ["rbind", ...] but I don't see a point to putting 'bind' in 'type' when it's not a filesystem type and you already have 'rbind' in 'options'. We could have stuck closer to that example with an unset type and: "options": ["rbind", ...] and that would have been closer to mount(8)'s --rbind API, but I've gone with 'recursive' here to stay closer to mount(2). This will scale better if/when we eventually add options for MS_SLAVE, etc. Since there are existing consumers using the old example format and similar things like: $ git log --oneline -1 | cat 03e8b89 Merge pull request #176 from hmeng-19/set_oom_score_adj $ ./ocitools generate --template <(echo '{}') --bind ab:cd:ro | jq '.mounts[0]' { "destination": "cd", "type": "bind", "source": "ab", "options": [ "bind", "ro" ] } this may be a breaking change for some spec consumers (although that ocitools example will still work, because 'options' contains 'bind', which means the 'type' will be ignored). But even if there are broken consumers, we're still pre-1.0, the spec never explained what bind/rbind meant before this commit, and consolidating the Linux mount spec around mount(2) now will make life less confusing in the future. Signed-off-by: W. Trevor King <[email protected]>
1 parent c66adcc commit 05b3277

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

config.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,24 @@ Each container has exactly one *root filesystem*, specified in the *root* object
4141

4242
You MAY add array of mount points inside container as `mounts`.
4343
The runtime MUST mount entries in the listed order.
44-
The parameters are similar to the ones in [the Linux mount system call](http://man7.org/linux/man-pages/man2/mount.2.html).
44+
The parameters are similar to the ones in [the Linux mount system call][mount.2].
4545

4646
* **`destination`** (string, required) Destination of mount point: path inside container.
4747
For the Windows operating system, one mount destination MUST NOT be nested within another mount (e.g., c:\\foo and c:\\foo\\bar).
48-
* **`type`** (string, required) The filesystem type of the filesystem to be mounted.
49-
Linux: *filesystemtype* argument supported by the kernel are listed in */proc/filesystems* (e.g., "minix", "ext2", "ext3", "jfs", "xfs", "reiserfs", "msdos", "proc", "nfs", "iso9660").
48+
* **`type`** (string, optional) The type of filesystem to mount.
49+
If `type` is unset, the runtime MAY ask the kernel to guess the desired type.
50+
Depending on the mount `options`, the `type` field MAY be ignored.
51+
For example, `type` is ignored when `options` contains `bind`; see the `MS_BIND` description in [mount(2)][mount.2].
52+
Linux: [*filesystemtype*][mount.2] values supported by the kernel are listed in */proc/filesystems* (e.g., "minix", "ext2", "ext3", "jfs", "xfs", "reiserfs", "msdos", "proc", "nfs", "iso9660").
5053
Windows: ntfs.
5154
* **`source`** (string, required) A device name, but can also be a directory name or a dummy.
5255
Windows: the volume name that is the target of the mount point, \\?\Volume\{GUID}\ (on Windows source is called target).
5356
* **`options`** (list of strings, optional) Mount options of the filesystem to be used.
5457
Linux: [supported][mount.8-filesystem-independent] [options][mount.8-filesystem-specific] are listed in [mount(8)][mount.8].
58+
Linux runtimes MUST also support the following options:
59+
60+
* `recursive`, with the semantics of [`MS_REC`][mount.2].
61+
* `bind`, with the semantics of [`MS_BIND`][mount.2].
5562

5663
### Example (Linux)
5764

@@ -65,9 +72,8 @@ The parameters are similar to the ones in [the Linux mount system call](http://m
6572
},
6673
{
6774
"destination": "/data",
68-
"type": "bind",
6975
"source": "/volumes/testing",
70-
"options": ["rbind","rw"]
76+
"options": ["recursive", "bind", "rw"]
7177
}
7278
]
7379
```
@@ -688,6 +694,8 @@ Here is a full example `config.json` for reference.
688694
[go-environment]: https://golang.org/doc/install/source#environment
689695
[runtime-namespace]: glossary.md#runtime-namespace
690696
[uts-namespace]: http://man7.org/linux/man-pages/man7/namespaces.7.html
697+
[mount.2]: http://man7.org/linux/man-pages/man2/mount.2.html
691698
[mount.8-filesystem-independent]: http://man7.org/linux/man-pages/man8/mount.8.html#FILESYSTEM-INDEPENDENT_MOUNT OPTIONS
692699
[mount.8-filesystem-specific]: http://man7.org/linux/man-pages/man8/mount.8.html#FILESYSTEM-SPECIFIC_MOUNT OPTIONS
700+
[mount.8-options]: http://man7.org/linux/man-pages/man8/mount.8.html#COMMAND-LINE_OPTIONS
693701
[mount.8]: http://man7.org/linux/man-pages/man8/mount.8.html

schema/defs.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,7 @@
152152
},
153153
"required": [
154154
"destination",
155-
"source",
156-
"type"
155+
"source"
157156
]
158157
},
159158
"ociVersion": {

specs-go/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ type Platform struct {
8585
type Mount struct {
8686
// Destination is the path where the mount will be placed relative to the container's root. The path and child directories MUST exist, a runtime MUST NOT create directories automatically to a mount point.
8787
Destination string `json:"destination"`
88-
// Type specifies the mount kind.
89-
Type string `json:"type"`
88+
// Type specifies the type of filesystem to mount.
89+
Type string `json:"type,omitempty"`
9090
// Source specifies the source path of the mount. In the case of bind mounts on
9191
// Linux based systems this would be the file on the host.
9292
Source string `json:"source"`

0 commit comments

Comments
 (0)