Skip to content

Commit 49a6f9d

Browse files
committed
*: flatten platform dependent source
This introduces verbiage of fields that may occur in json (technically optional), but is required on certain platforms (e.g. Linux). The JSON document will look the same as it presently does, but now the reference source compiles regardless of platform. Not adding a "name" string to the user sturct, as that is not a requirement yet. In the event a windows runtime shows up, I could imagine an `sid` on the user struct, but we'll get to that when it happens. Closes #135 Related to #166 Signed-off-by: Vincent Batts <[email protected]>
1 parent 52cbf47 commit 49a6f9d

File tree

8 files changed

+395
-406
lines changed

8 files changed

+395
-406
lines changed

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ DOC_FILES := \
1111
runtime.md \
1212
runtime-linux.md \
1313
config.md \
14-
config-linux.md \
1514
runtime-config.md \
1615
runtime-config-linux.md \
1716
glossary.md

config-linux.md

Lines changed: 0 additions & 39 deletions
This file was deleted.

config.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ type Spec struct {
1616
Hostname string `json:"hostname,omitempty"`
1717
// Mounts profile configuration for adding mounts to the container's filesystem.
1818
Mounts []MountPoint `json:"mounts"`
19+
20+
// Linux is platform specific configuration for linux based containers. (this field is platform dependent)
21+
Linux Linux `json:"linux,omitempty" platform:"linux"`
1922
}
2023

2124
// Process contains information to start a specific application inside the container.
@@ -33,6 +36,17 @@ type Process struct {
3336
Cwd string `json:"cwd"`
3437
}
3538

39+
// User specifies linux specific user and group information for the container's
40+
// main process.
41+
type User struct {
42+
// UID is the user ID the Process is executed as. (this field is platform dependent)
43+
UID uint32 `json:"uid,omitempty" platform:"linux"`
44+
// GID is the group ID the Process is executed as. (this field is platform dependent)
45+
GID uint32 `json:"gid,omitempty" platform:"linux"`
46+
// AdditionalGids are additional group ids set for the container's process. (this field is platform dependent)
47+
AdditionalGids []uint32 `json:"additionalGids,omitempty" platform:"linux"`
48+
}
49+
3650
// Root contains information about the container's root filesystem on the host.
3751
type Root struct {
3852
// Path is the absolute path to the container's root filesystem.
@@ -57,3 +71,9 @@ type MountPoint struct {
5771
// Path specifies the path of the mount. The path and child directories MUST exist, a runtime MUST NOT create directories automatically to a mount point.
5872
Path string `json:"path"`
5973
}
74+
75+
// Linux contains platform specific configuration for linux based containers.
76+
type Linux struct {
77+
// Capabilities are linux capabilities that are kept for the container.
78+
Capabilities []string `json:"capabilities"`
79+
}

config.md

Lines changed: 58 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ Each container has exactly one *root filesystem*, specified in the *root* object
2828
*Example*
2929

3030
```json
31-
"root": {
31+
"root": {
3232
"path": "rootfs",
3333
"readonly": true
34-
}
34+
}
3535
```
3636

3737
## Mount Points
@@ -46,24 +46,24 @@ The runtime MUST mount entries in the listed order.
4646
*Example*
4747

4848
```json
49-
"mounts": [
49+
"mounts": [
5050
{
51-
"name": "proc",
52-
"path": "/proc"
51+
"name": "proc",
52+
"path": "/proc"
5353
},
5454
{
55-
"name": "dev",
56-
"path": "/dev"
55+
"name": "dev",
56+
"path": "/dev"
5757
},
5858
{
59-
"name": "devpts",
60-
"path": "/dev/pts"
59+
"name": "devpts",
60+
"path": "/dev/pts"
6161
},
6262
{
63-
"name": "data",
64-
"path": "/data"
63+
"name": "data",
64+
"path": "/data"
6565
}
66-
]
66+
]
6767
```
6868

6969
## Process configuration
@@ -76,9 +76,9 @@ The runtime MUST mount entries in the listed order.
7676
The user for the process is a platform-specific structure that allows specific control over which user the process runs as.
7777
For Linux-based systems the user structure has the following fields:
7878

79-
* **`uid`** (int, required) specifies the user id.
80-
* **`gid`** (int, required) specifies the group id.
81-
* **`additionalGids`** (array of ints, optional) specifies additional group ids to be added to the process.
79+
* **`uid`** (int, required on Linux) specifies the user id.
80+
* **`gid`** (int, required on Linux) specifies the group id.
81+
* **`additionalGids`** (array of ints, optional on Linux) specifies additional group ids to be added to the process.
8282

8383
*Example (Linux)*
8484

@@ -101,7 +101,6 @@ For Linux-based systems the user structure has the following fields:
101101
}
102102
```
103103

104-
105104
## Hostname
106105

107106
* **`hostname`** (string, optional) as it is accessible to processes running inside. On Linux, you can only set this if your bundle creates a new [UTS namespace][uts-namespace].
@@ -117,6 +116,8 @@ For Linux-based systems the user structure has the following fields:
117116
* **`os`** (string, required) specifies the operating system family this image must run on. Values for os must be in the list specified by the Go Language document for [`$GOOS`](https://golang.org/doc/install/source#environment).
118117
* **`arch`** (string, required) specifies the instruction set for which the binaries in the image have been compiled. Values for arch must be in the list specified by the Go Language document for [`$GOARCH`](https://golang.org/doc/install/source#environment).
119118

119+
*Example*
120+
120121
```json
121122
"platform": {
122123
"os": "linux",
@@ -125,6 +126,46 @@ For Linux-based systems the user structure has the following fields:
125126
```
126127

127128
Interpretation of the platform section of the JSON file is used to find which platform-specific sections may be available in the document.
128-
For example, if `os` is set to `linux`, then a JSON object conforming to the [Linux-specific schema](config-linux.md) SHOULD be found at the key `linux` in the `config.json`.
129+
For example, if `os` is set to `linux`, then a JSON object conforming to the [Linux-specific schema](#linux-specific-container-configuration) SHOULD be found at the key `linux` in the `config.json`.
130+
131+
## Linux-specific Container Configuration
132+
133+
The Linux container specification.
134+
uses various kernel features like namespaces, cgroups, capabilities, LSM, and file system jails to fulfill the spec.
135+
136+
### Capabilities
137+
138+
Capabilities is an array that specifies Linux capabilities that can be provided to the process inside the container.
139+
Valid values are the strings for capabilities defined in [the man page](http://man7.org/linux/man-pages/man7/capabilities.7.html)
140+
141+
```json
142+
"capabilities": [
143+
"CAP_AUDIT_WRITE",
144+
"CAP_KILL",
145+
"CAP_NET_BIND_SERVICE"
146+
]
147+
```
148+
149+
### Default Devices and File Systems
150+
151+
The Linux ABI includes both syscalls and several special file paths.
152+
Applications expecting a Linux environment will very likely expect these files paths to be setup correctly.
153+
154+
The following devices and filesystems MUST be made available in each application's filesystem
155+
156+
| Path | Type | Notes |
157+
| ------------ | ------ | ------- |
158+
| /proc | [procfs](https://www.kernel.org/doc/Documentation/filesystems/proc.txt) | |
159+
| /sys | [sysfs](https://www.kernel.org/doc/Documentation/filesystems/sysfs.txt) | |
160+
| /dev/null | [device](http://man7.org/linux/man-pages/man4/null.4.html) | |
161+
| /dev/zero | [device](http://man7.org/linux/man-pages/man4/zero.4.html) | |
162+
| /dev/full | [device](http://man7.org/linux/man-pages/man4/full.4.html) | |
163+
| /dev/random | [device](http://man7.org/linux/man-pages/man4/random.4.html) | |
164+
| /dev/urandom | [device](http://man7.org/linux/man-pages/man4/random.4.html) | |
165+
| /dev/tty | [device](http://man7.org/linux/man-pages/man4/tty.4.html) | |
166+
| /dev/console | [device](http://man7.org/linux/man-pages/man4/console.4.html) | |
167+
| /dev/pts | [devpts](https://www.kernel.org/doc/Documentation/filesystems/devpts.txt) | |
168+
| /dev/ptmx | [device](https://www.kernel.org/doc/Documentation/filesystems/devpts.txt) | Bind-mount or symlink of /dev/pts/ptmx |
169+
| /dev/shm | [tmpfs](https://www.kernel.org/doc/Documentation/filesystems/tmpfs.txt) | |
129170

130171
[uts-namespace]: http://man7.org/linux/man-pages/man7/namespaces.7.html

config_linux.go

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)