|
| 1 | +# <a name="FreeBSDContainerConfiguration" />FreeBSD Container Configuration |
| 2 | + |
| 3 | +This document describes the schema for the [FreeBSD-specific section](config.md#platform-specific-configuration) of the [container configuration](config.md). |
| 4 | + |
| 5 | +## <a name="configFreeBSDDevices" />Devices |
| 6 | + |
| 7 | +Devices in FreeBSD are accessed via the `devfs` filesystem. Typically, each container will have a `devfs` filesystem mounted into its `/dev` directory. Often, a minimal set of devices is exposed to the container using ruleset 4 from `/etc/defaults/devfs.rules` - the ruleset is specified as a mount option. |
| 8 | + |
| 9 | +Optionally, additional devices can be exposed to the container using an array of entries inside the `devices` root field: |
| 10 | + |
| 11 | +* **`path`** _(string, REQUIRED)_ - the device path relative to `/dev` |
| 12 | +* **`mode`** _(string, OPTIONAL)_ - device permissions mode string as defined in [`chmod(1)`](https://man.freebsd.org/cgi/man.cgi?query=chmod). |
| 13 | + |
| 14 | +### Example |
| 15 | +```json |
| 16 | +"devices": [ |
| 17 | + { |
| 18 | + "path": "pf", |
| 19 | + "mode": "0700" |
| 20 | + } |
| 21 | +] |
| 22 | +``` |
| 23 | + |
| 24 | +## <a name="configFreeBSDJail" />Jail |
| 25 | + |
| 26 | +On FreeBSD, containers are implemented using the platform's jail subsystem. Configuration for the container jail is via fields inside the `jail` root field: |
| 27 | + |
| 28 | +* **`parent`** _(string, OPTIONAL)_ - parent jail. |
| 29 | + The value is the name of a jail which should be this container's parent (defaults to none). This can be used to share namespaces such as `vnet` with another container. |
| 30 | +* **`host`** _(string, OPTIONAL)_ - allow overriding hostname, domainname, hostuuid and hostid. |
| 31 | + The value can be "new" which allows these values to be overridden in the container or "inherit" to use the host values (or parent container values). If set to "new", the values for hostname and domainname are taken from the base config, if present. |
| 32 | +* **`ip4`** _(string, OPTIONAL)_ - control the availability of IPv4 addresses. |
| 33 | + This is typically left unset if the container has a vnet, set to "inherit" to allow access to host (or parent container) addresses or set to "disable" to stop use of IPv4 entirely. |
| 34 | +* **`ip6`** _(string, OPTIONAL)_ - control the availability of IPv6 addresses. |
| 35 | + This is typically left unset if the container has a vnet, set to "inherit" to allow access to host (or parent container) addresses or set to "disable" to stop use of IPv6 entirely. |
| 36 | +* **`vnet`** _(string, OPTIONAL)_ - control the vnet used for this container. |
| 37 | + The value can be "new" which causes a new vnet to be created for the container or "inherit" which shares the vnet for the parent container (or host if there is no parent). |
| 38 | +* **`sysvmsg`** _(string, OPTIONAL)_ - allow access to SYSV IPC message primitives. |
| 39 | + If set to "inherit", all IPC objects on the system are visible to this container, whether they were created by the container itself, the base system, or other containers. If set to "new", the container will have its own key namespace, and can only see the objects that it has created; the system (or parent container) has access to the container's objects, but not to its keys. If set to "disable", the container cannot perform any sysvmsg-related system calls. Defaults to "new". |
| 40 | +* **`sysvsem`** _(string, OPTIONAL)_ - allow access to SYSV IPC semaphore primitives, in the same manner as sysvmsg. Defaults to "new". |
| 41 | +* **`sysvshm`** _(string, OPTIONAL)_ - allow access to SYSV IPC shared memory primitives, in the same manner as sysvmsg. Defaults to "new". |
| 42 | +* **`enforceStatfs`** _(integer, OPTIONAL)_ - control visibility of mounts in the container. |
| 43 | + A value of 0 allows visibility of all host mounts, 1 allows visibility of mounts nested under the container's root and 2 only allows the container root to be visible. If unset, the default value is 2. |
| 44 | +* **`allow`** _(object, OPTIONAL)_ - Some restrictions of the container environment may be set on a per-container basis. With the exception of **`setHostname`** and **`reservedPorts`**, these boolean parameters are off by default. |
| 45 | + - **`setHostname`** _(bool, OPTIONAL)_ - Allow the container's hostname to be changed. Defaults to `false`. |
| 46 | + - **`rawSockets`** _(bool, OPTIONAL)_ - Allow the container to use raw sockets to support network utilities such as ping and traceroute. Defaults to `false`. |
| 47 | + - **`chflags`** _(bool, OPTIONAL)_ - Allow the system file flags to be changed. Defaults to `false`. |
| 48 | + - **`mount`** _(array of strings, OPTIONAL)_ - Allow the listed filesystem types to be mounted and unmounted in the container. |
| 49 | + - **`quotas`** _(bool, OPTIONAL)_ - Allow the filesystem quotas to be changed in the container. Defaults to `false`. |
| 50 | + - **`socketAf`** _(bool, OPTIONAL)_ - Allow socket types other than IPv4, IPv6 and unix. Defaults to `false`. |
| 51 | + - **`reservedPorts`** _(bool, OPTIONAL)_ - Allow the jail to bind to ports lower than 1024. Defaults to `false`. |
| 52 | + - **`suser`** _(bool, OPTIONAL)_ - The value of the jail's security.bsd.suser_enabled sysctl. The super-user will be disabled automatically if its parent system has it disabled. The super-user is enabled by default. |
| 53 | + |
| 54 | +### Mapping from jail(8) config file |
| 55 | + |
| 56 | +This table defines the mappings from a typical `jail(8)` config file to the container configuration: |
| 57 | + |
| 58 | +| Jail parameter | JSON equivalent | |
| 59 | +| -------------- | -------------------- | |
| 60 | +| `jid` | - | |
| 61 | +| `name` | see below | |
| 62 | +| `path` | `root.path` | |
| 63 | +| `ip4.addr` | - | |
| 64 | +| `ip4.saddrsel` | - | |
| 65 | +| `ip4` | `freebsd.jail.ip4` | |
| 66 | +| `ip6.addr` | - | |
| 67 | +| `ip6.saddrsel` | - | |
| 68 | +| `ip6` | `freebsd.jail.ip6` | |
| 69 | +| `vnet` | `freebsd.jail.vnet` | |
| 70 | +| `host.hostname` | `hostname` | |
| 71 | +| `host` | `freebsd.jail.host` | |
| 72 | +| `sysvmsg` | `freebsd.jail.sysvmsg` | |
| 73 | +| `sysvsem` | `freebsd.jail.sysvsem` | |
| 74 | +| `sysvshm` | `freebsd.jail.sysvshm` | |
| 75 | +| `securelevel` | - | |
| 76 | +| `devfs_ruleset` | see below | |
| 77 | +| `children.max` | see below | |
| 78 | +| `enforce_statfs` | `freebsd.jail.enforceStatfs` | |
| 79 | +| `persist` | - | |
| 80 | +| `parent` | `freebsd.jail.parent` | |
| 81 | +| `osrelease` | - | |
| 82 | +| `osreldate` | - | |
| 83 | +| `allow.set_hostname` | `freebsd.jail.allow.setHostname` | |
| 84 | +| `allow.sysvipc` | `freebsd.jail.allow.sysvipc` | |
| 85 | +| `allow.raw_sockets` | `freebsd.jail.allow.rawSockets` | |
| 86 | +| `allow.chflags` | `freebsd.jail.allow.chflags` | |
| 87 | +| `allow.mount` | `freebsd.jail.allow.mount` | |
| 88 | +| `allow.quotas` | `freebsd.jail.allow.quotas` | |
| 89 | +| `allow.read_msgbuf` | - | |
| 90 | +| `allow.socket_af` | `freebsd.jail.allow.socketAf` | |
| 91 | +| `allow.mlock` | - | |
| 92 | +| `allow.nfsd` | - | |
| 93 | +| `allow.reserved_ports` | `freebsd.jail.allow.reservedPorts` | |
| 94 | +| `allow.unprivileged_proc_debug` | - | |
| 95 | +| `allow.suser` | `freebsd.jail.allow.suser` | |
| 96 | +| `allow.mount.*` | see below | |
| 97 | + |
| 98 | +The jail name SHOULD be set to the create command's `container-id` argument. |
| 99 | + |
| 100 | +Network addresses are typically managed by the host (e.g. using CNI or netavark) so we do not include a mapping for `ip4.addr` or `ip6.addr`. |
| 101 | + |
| 102 | +The `devfs_ruleset` parameter is only required for jails which create new `devfs` mounts - typically OCI runtimes will mount `devfs` on the host. The value is a rule set number - these rule sets are defined on the host, typically via `/etc/defaults/devfs.rules` or using the `devfs` command line utility. |
| 103 | + |
| 104 | +The `children.max` parameter SHOULD be managed by the OCI runtime e.g when a new container shares namespaces with an existing container. |
| 105 | + |
| 106 | +The `allow.mount.*` parameter set is extensible - allowed mount types are listed as an array. As with `devfs`, typically the OCI runtime will manage mounts for the container by performing mount operations on the host. |
| 107 | + |
| 108 | +Jail parameters not supported by this runtime extension are marked with "-". These parameters will have their default values - see the `jail(8)` man page for details. |
| 109 | + |
| 110 | +### Example |
| 111 | +```json |
| 112 | +"jail": { |
| 113 | + "host": "new", |
| 114 | + "vnet": "new", |
| 115 | + "enforceStatfs": 1, |
| 116 | + "allow": { |
| 117 | + "rawSockets": true, |
| 118 | + "chflags": true, |
| 119 | + "mount": [ |
| 120 | + "tmpfs" |
| 121 | + ] |
| 122 | + } |
| 123 | +} |
| 124 | +``` |
0 commit comments