|
| 1 | +# CBSD and OCI containers |
| 2 | + |
| 3 | +## Description |
| 4 | + |
| 5 | +The CBSD can use two formats for distributing virtual machine and container images - its own and [OCI containers](https://opencontainers.org/). |
| 6 | +There is a misconception that with the advent of OCI all container managers on FreeBSD are deprecated. |
| 7 | + |
| 8 | +There are a few points to note here: |
| 9 | + |
| 10 | +- OCI is an image standard, it does not regulate how exactly to work with the image; |
| 11 | +- for 2025y, OCI takes into account and focuses on the capabilities of Linux systems and in particular, the use of groups/FS layers/namespaces. Thus, many things (capabilities, plugins) on FreeBSD marked as: "not supported yet". |
| 12 | +As an example - namespaces. For example, in OCI, containers may have 'sysctl' parameters which is widely used - FreeBSD will not allow you to do this: |
| 13 | +``` |
| 14 | +# A list of sysctls to be set in containers by default, |
| 15 | +# specified as "name=value", |
| 16 | +# for example:"net.ipv4.ping_group_range=0 0". |
| 17 | +# |
| 18 | +default_sysctls = [ |
| 19 | + "net.ipv4.ping_group_range=0 0", |
| 20 | +] |
| 21 | +``` |
| 22 | +- The official FreeBSD Handbook describes classic jail as `FreeBSD basejail` mounted as RO (nullfs) and overlay data mounted in RW (nullfs). |
| 23 | + This is a fundamental difference in the approach to using images, and when someone says "FreeBSD jail managers is obsolete", this approach is meant. |
| 24 | + However, it is a relevant approach for freeBSD. Moreover, nothing prevents you from using it in OSI images oriented for FreeBSD - CBSD allows it. |
| 25 | + |
| 26 | +## How to work with OCI |
| 27 | + |
| 28 | +The integration of CBSD and the OCI is achieved using a `buildah` tools. |
| 29 | +For this reason, if you plan to use OCI images - you must install package and run CBSD reinitialization: |
| 30 | +``` |
| 31 | +pkg install -y buildah |
| 32 | +cbsd initenv |
| 33 | +``` |
| 34 | + |
| 35 | +If the `buildah` utility is installed, CBSD will start using OCI images automatically in addition to its own images. Check out the current examples in: |
| 36 | +``` |
| 37 | +cbsd images --help |
| 38 | +cbsd jstart --help |
| 39 | +``` |
| 40 | + |
| 41 | +Example1: native FreeBSD image (base-in-pkg-based): |
| 42 | + |
| 43 | +``` |
| 44 | +cbsd jcreate jname=test ver=empty baserw=1 pkg_bootstrap=0 floatresolv=0 applytpl=0 etcupdate_init=0 from=docker.io/convectix/freebsd14-base runasap=1 |
| 45 | +cbsd jlogin test |
| 46 | +
|
| 47 | +root@test:~ # telnet |
| 48 | +Command 'telnet' not found, but can be installed with: |
| 49 | +pkg install -y FreeBSD-telnet |
| 50 | +``` |
| 51 | + |
| 52 | +Example1: Linux image |
| 53 | + |
| 54 | +``` |
| 55 | +cbsd jcreate jname=test2 ver=empty baserw=1 pkg_bootstrap=0 floatresolv=0 applytpl=0 etcupdate_init=0 exec_start=/bin/true exec_stop=/bin/true from=docker.io/library/alpine emulator=linux runasap=1 |
| 56 | +cbsd jlogin test |
| 57 | +
|
| 58 | +cbsd@test2> uname -a |
| 59 | +Linux test2.my.domain 5.15.0 FreeBSD 14.2-RELEASE releng/14.2-n269506-c8918d6c741 GENERIC x86_64 Linux |
| 60 | +cbsd@test2> cat /etc/os-release |
| 61 | +NAME="Alpine Linux" |
| 62 | +ID=alpine |
| 63 | +VERSION_ID=3.20.3 |
| 64 | +PRETTY_NAME="Alpine Linux v3.20" |
| 65 | +HOME_URL="https://alpinelinux.org/" |
| 66 | +BUG_REPORT_URL="https://gitlab.alpinelinux.org/alpine/aports/-/issues" |
| 67 | +``` |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | +## Errata |
| 72 | + |
| 73 | +- Support for `buildah/OCI` is experimental (Also `buildah` package is marked as experimental by itself) - do not use it in production; |
| 74 | +- CBSD uses `buildah` tool only to get an image (or generate and push a jail container to the Docker registry); |
| 75 | +- At the moment CBSD ignores OCI image `Entrypoints` - work is underway on integration with CBSD daemonize; |
| 76 | +- CBSD uses a `buildah` with alternative paths (to store data in the CBSD hier/structure). If you have difficulties with the build, call it with arguments, which you will see in the output |
| 77 | + |
0 commit comments