Skip to content

Add FreeBSD as a platform #1286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

dfr
Copy link

@dfr dfr commented May 5, 2025

This uses FreeBSD jails to implement container isolation.

@AkihiroSuda
Copy link
Member

Cc @samuelkarp

config.md Outdated
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

features.md needs an update too

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I originally looked at features.md, it seemed that the only platform-specific features are for Linux. So far, I don't think we have a need for platform features on FreeBSD.

@dfr dfr force-pushed the freebsd-spec branch from 8c7900f to e5803c8 Compare May 5, 2025 16:35
Copy link
Member

@tianon tianon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few initial (high level) thoughts 👍❤️


## <a name="configFreeBSDDevices" />Devices

Devices in FreeBSD are accessed via the `devfs` filesystem. Typically, each container will have a `devfs` filesystem mounted into it's `/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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typically, each container will have a devfs filesystem mounted into it's /dev directory.

What are the cases where they wouldn't? Does any of what's specified here no longer work in those cases? (Do we need a stronger requirement here, or is the status quo fine?)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems fine to me.

devfs includes /dev/std{in,out,err} /dev/null and more, optionally /dev/pf for firewall (FreeBSD has a container-enabled virtualised network & firewall stack), and /dev/zfs filesystem functionality is exposed this way, etc.

@dfr s/it's/its/ though?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typically, each container will have a devfs filesystem mounted into it's /dev directory.

What are the cases where they wouldn't? Does any of what's specified here no longer work in those cases? (Do we need a stronger requirement here, or is the status quo fine?)

In theory, you could do without /dev for very simple workloads which don't need /dev/null, /dev/zero, good random numbers etc. but in practice, the suggested devfs ruleset for jails (look for ruleset 4 in /etc/defaults/devfs.conf on a FreeBSD host) is sufficient for most workloads. Container engines such as Podman, containerd etc. all add a /dev mount point using ruleset 4.

"devices": [
{
"path": "pf",
"mode": "0700"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it an integer or a string? 😅

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it has to be a string because JSON representation of an octal "0700" as a number would be 448 in decimalised JSON...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a string which is interpreted as in chmod(1) which supports octal numeric modes as well as symbolic. I will fix the text to make this a little clearer.

]
```

## <a name="configFreeBSDJail" />Jail
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section feels to me more like documentation for an existing implementation than specification from which a new compatible implementation could be implemented. 🤔

Are there specific features of FreeBSD that could be explicitly named here to help connect these things more strongly? Are there any places here where SHOULD or MUST language would be appropriate?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section is informational and is intended as a guide for readers familiar with FreeBSD jails to help them understand the mapping from the FreeBSD OCI config settings to the corresponding jail.

Since this proposal only covers the use of FreeBSD jails to implement OCI containers, there is very little freedom for implementors. The text following the table would benefit from using SHOULD/MUST language.


### Mapping from jail(8) config file

This table shows how to map settings from a typical `jail(8)` config file to the container configuration:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this advisory/suggestion, or prescriptive? (It currently reads as the former)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, I think we can say This tables defines the mappings from a typical here. Does that read better?

| `allow.suser` | `freebsd.jail.allow.suser` |
| `allow.mount.*` | see below |

The jail name is set to the create command's `container-id` argument.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"is", SHOULD, or MUST? (Another place that feels like documentation, not spec)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless there is another mechanism to (externally from the runtime) link jail name with container-id this should be MUST.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the whole table, I'm not sure. If any of these parameters are used, the mappy is prescriptive. Is that MUST or SHOULD?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My current draft has SHOULD for the jail name - the use case is to facilitate higher-level software which needs to be able to access the jail, e.g. to monitor resource metrics. Perhaps MUST would be better here.

@AkihiroSuda AkihiroSuda added this to the v1.3.0 milestone May 6, 2025
Optionally, additional devices can be exposed to the container using an array of entries inside the `devices` root field:

* **`path`** _(string, REQUIRED)_ - the device path relative to `/dev`
* **`mode`** _(integer, OPTIONAL)_ - device permissions as an integer which is interpreted as in `chmod(1)`.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.. should mode be annotated as string here?

What about:

"device permissions as an exact string representation of permissions expressed in octal, with leading "0" as in chmod(1), for example "0700".

Maybe more precise, but feels clumsy to me. Suggestions?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm comfortable just referring to chmod(1) for definitive definitions. I'll try to make this link to the FreeBSD man page.

This uses FreeBSD jails to implement container isolation.

Signed-off-by: Doug Rabson <[email protected]>
@dfr
Copy link
Author

dfr commented May 23, 2025

Fixed the type of FreeBSDDevice.Mode and fixed a typo in the json mapping for FreeBSDJail.SysVShm.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants