Skip to content

Commit 83914ed

Browse files
committed
runtime: Clarify UTS and mount cleanup on 'delete'
Now that d43fc42 (config-linux: Lift no-tweaking namespace restriction, 2017-01-11, opencontainers#649) allows us to get into this sort of situation. This sort of ownership may also apply to other resources (cgroups?), but we can handle them in follow-up commits. Also drop "Configuration" from the root header. Everything in that file is a configuration. container-namespace3 (instead of container-namespace) supports the single-page, Pandoc-generated file (see e7be40f, Cleanup the spec a bit to remove WG/git text that's not really part of the spec, 2016-11-14, opencontainers#626). Using an informative suggestion was recommended by Dao Quang Minh [1]. I've made the config JSON as small as possible while keeping it valid, but there's still an unfortunate amount of boilerplate there. There is in-flight work to let us at least drop process.args [2]. [1]: opencontainers#651 [2]: opencontainers#620 Signed-off-by: W. Trevor King <[email protected]>
1 parent c368be6 commit 83914ed

File tree

2 files changed

+86
-4
lines changed

2 files changed

+86
-4
lines changed

config.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ For example, if a configuration is compliant with version 1.1 of this specificat
2020
"ociVersion": "0.1.0"
2121
```
2222

23-
## Root Configuration
23+
## Root
2424

2525
**`root`** (object, REQUIRED) configures the container's root filesystem.
2626

@@ -41,7 +41,7 @@ For example, if a configuration is compliant with version 1.1 of this specificat
4141

4242
## Mounts
4343

44-
**`mounts`** (array, OPTIONAL) configures additional mounts (on top of [`root`](#root-configuration)).
44+
**`mounts`** (array, OPTIONAL) configures additional mounts (on top of [`root`](#root)).
4545
The runtime MUST mount entries in the listed order.
4646
The parameters are similar to the ones in [the Linux mount system call](http://man7.org/linux/man-pages/man2/mount.2.html).
4747
For Solaris, the mounts corresponds to fs resource in zonecfg(8).

runtime.md

Lines changed: 84 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,93 @@ When the process in the container is stopped, irrespective of it being as a resu
121121
This operation MUST generate an error if it is not provided the container ID.
122122
Attempting to delete a container that does not exist MUST generate an error.
123123
Attempting to delete a container whose process is still running MUST generate an error.
124-
Deleting a container MUST delete the resources that were created during the `create` step.
125-
Note that resources associated with the container, but not created by this container, MUST NOT be deleted.
126124
Once a container is deleted its ID MAY be used by a subsequent container.
127125

126+
Deleting a container MUST delete the resources that were created during the `create` step.
127+
Resources associated with the container, but not created by this container, MUST NOT be altered.
128+
129+
#### Examples of resource ownership
130+
131+
This section contains informative elaborations of the above “resources created by the container” requirements.
132+
It is not intended to be exhaustive.
133+
134+
##### Joining mount namespaces (Linux)
135+
136+
A container joins an existing [mount namespace](config-linux.md#namespaces) on Linux and pivots [root](config.md#root) into the `rootfs` directory with the following [configuration](config.md):
137+
138+
```json
139+
{
140+
"ociVersion": "1.0.0-rc3",
141+
"platform": {
142+
"os": "linux",
143+
"arch": "amd64"
144+
},
145+
"process": {
146+
"cwd": "/",
147+
"args": [
148+
"sh"
149+
],
150+
"user": {
151+
"uid": 1,
152+
"gid": 1
153+
}
154+
},
155+
"root": {
156+
"path": "rootfs"
157+
},
158+
"linux": {
159+
"namespaces": [
160+
{
161+
"type": "mount",
162+
"path": "/proc/1234/ns/mnt"
163+
}
164+
]
165+
}
166+
}
167+
```
168+
169+
When the example container is deleted, neither removing the preexisting mount namespace nor undoing the pivot into `rootfs` are allowed.
170+
171+
##### Joining UTS namespaces (Linux)
172+
173+
A container joins an existing [UTS namespace](config-linux.md#namespaces) on Linux and changes the [hostname](config.md#hostname) with the following [configuration](config.md):
174+
175+
```json
176+
{
177+
"ociVersion": "1.0.0-rc3",
178+
"platform": {
179+
"os": "linux",
180+
"arch": "amd64"
181+
},
182+
"process": {
183+
"cwd": "/",
184+
"args": [
185+
"sh"
186+
],
187+
"user": {
188+
"uid": 1,
189+
"gid": 1
190+
}
191+
},
192+
"root": {
193+
"path": "rootfs"
194+
},
195+
"hostname": "alice",
196+
"linux": {
197+
"namespaces": [
198+
{
199+
"type": "uts",
200+
"path": "/proc/1234/ns/uts"
201+
}
202+
]
203+
}
204+
}
205+
```
206+
207+
When the example container is deleted, neither removing the preexisting UTS namespace nor undoing the hostname change are allowed.
128208

129209
## Hooks
130210
Many of the operations specified in this specification have "hooks" that allow for additional actions to be taken before or after each operation.
131211
See [runtime configuration for hooks](./config.md#hooks) for more information.
212+
213+
[container-namespace3]: glossary.md#container-namespace

0 commit comments

Comments
 (0)