|
|
Log in / Subscribe / Register

Containers as a recognized kernel object

By Jonathan Corbet
October 29, 2026
The foundation of the design for containers in the kernel is that there isn't one; there is no container abstraction that the kernel recognizes. Instead, the kernel provides a long list of components — namespaces, control groups, sandboxing mechanisms, and more — along with a note that says, in effect, "some assembly required". There have been attempts (repeatedly) over the years to turn containers into first-class objects with kernel support, but they have never gotten far. Now Josef Bacik is making a try with a concept that he calls "cells".

Some years ago, the lack of any sort of kernel-supported container object was arguably the right approach; there was still a lot to be learned about how this concept should be integrated into Linux. Some would surely argue that it is still a good idea. But there are downsides as well, starting with the complexity of creating a container. Beyond that, though, since the kernel has no notion of containers, it cannot enforce a container's properties and cannot even answer questions about which container a process might belong to. Containers are created by walling off parts of the larger system. Namespaces are created then entered, filesystems are unmounted or overmounted to make them inaccessible inside the container, and so on. This sequence means that any given process might be only partly inside a container, a situation that, according to Bacik, "is where a depressing number of our bugs come from". The current approach to container creation also makes it easy to let unwanted resources leak into the container from the outside.

Introducing cells

Bacik's proposal is an attempt to address these problems. A container (called a "cell" in this series), when created, contains nothing at all. No processes or filesystems show up there by default. Anything that the creator wants to exist in a cell must be explicitly put there. Processes and other resources created within a cell are not allowed to to leave that cell. In theory, cells should be easier to manage and easier to keep secure than containers as they exist in Linux now.

A cell's life starts with a call to cell_create():

    int cell_create(int parent, unsigned int flags);

The parent parameter is seemingly meant to designate which process will be the parent of the new cell, but in the current implementation the only allowed value is CELL_SELF, meaning that the creator is the parent. The flags argument must be zero. The return value, if all goes well, is a "cellfd" — a file descriptor referring to this cell. The cellfd is special, in that it is the handle that is used to perform all other operations on the cell. There is no way to create a duplicate cellfd that possesses the same capabilities. Creating a cell is an unprivileged operation.

If the cellfd is closed, the cell (and anything contained within it) is immediately killed. There is also a system call to kill a cell explicitly:

    int cell_kill(int cellfd, unsigned int flags);

Where cellfd identifies the cell to kill, and flags must be zero.

An empty cell is secure and bug-free, but it is also rather boring. There is another system call that is used to set various properties of this cell to make it more interesting:

    int cell_configure(int cellfd, unsigned int cmd, const char *key,
    		       const void *value, int aux);

This system call applies the given configuration cmd to the cell identified by cellfd; the key string identifies which property is to be changed. The available commands are:

CELL_SET_FLAG
Sets the flag named by key; there are no flags defined in the current proposal, though.
CELL_SET_STRING
Sets the string value given by key to the given value. Two strings are supported in the initial patch set: hostname to set the host name within the cell, and net, which sets the network namespace for the cell. By default, the cell has no network access, and only AF_UNIX sockets can be created within it. Setting the net key to new creates a new network namespace that the builder will subsequently configure, while own creates a network namespace owned by the cell itself and configured internally. In the new case, there is another new system call (cell_open()) that must be used to obtain a file descriptor for the newly created namespace. The network namespace can also be explicitly set with CELL_SET_FD, described below.
CELL_SET_BINARY
Sets the property identified by key to the provided binary data. The only value accepted is ids, which is used to define which user IDs will be used within the cell. There are only two allowed values. Setting it to one causes processes within the cell to run with the same user ID as the creator; this mode is not allowed for the root user.

Otherwise, the ids key must be set to 65,536, which causes a block of that many IDs to be allocated from the upper part of the 32-bit user-ID space. These IDs will be unique on the running system, and the cell creator has no control over what they will be. It is not possible to create files owned by those IDs in any filesystem outside of the cell. This part of the design has drawn some comments and may change (perhaps by providing an entirely separate user-ID space for cell inmates) in the future.

CELL_SET_FD
Sets a value requiring a file descriptor. There are three of those implemented in this patch set. root is a filesystem namespace that contains the root filesystem within the cell, net is a network namespace to be used by the cell, and budget is a control-group directory. The budget is mandatory, and each cell must have its own control group.
CELL_CMD_SEAL
Once the configuration of the cell is complete, this command must be issued; it completes the initialization of the cell and prevents any further configuration changes.

Once the cell is sealed, it is set up with a filesystem tree, control-group membership, and the rest of the namespaces that control its interactions with the rest of the system. It is still otherwise empty, though, with no processes running within it. In Bacik's design, there is no way for an existing process to enter a cell; setns() cannot be used to enter its namespaces. Instead, processes must be born within the cell from the beginning, and they can never exit the cell.

Creating inmate processes

Allowing the creation of processes with life sentences inside a cell involves yet another proposal for a process-builder API; the last such attempt was covered here in August. Here, the first step is to create the process within the cell with a variant of the pidfd_open() system call. Rather than passing a process ID to pidfd_open(), the cell creator passes the cellfd and the PIDFD_EMPTY flag. The return value is a pidfd that does not, yet, refer to a running task; it is in the "embryo" state at this point.

Once the pidfd is created, it must be configured with another new system call before it can run anything useful:

    int pidfd_configure(int pidfd, unsigned int cmd, const char *key,
    		        const void *value, int aux);

The interface looks much like that of cell_configure(), and it operates in mostly the same way. The process to configure (which must be in the embryo state) is specified by pidfd; the cmd value is one of:

PIDFD_SET_STRING
The only supported key is exec, which names the executable file (within the cell's mount namespace) that the process will run.
PIDFD_SET_BINARY
Sets a key to binary data. Recognized keys are argv to set the processes argument vector, envp to set its environment variables, and cred, which sets the process's user and group IDs within the cell's user namespace.
PIDFD_SET_FD
Sets a file descriptor in the embryo process; the key is the file-descriptor number (as a string), and the aux parameter is an open file descriptor in the caller's file table. The only open file descriptors the process will have are those set up with PIDFD_SET_FD, so there should be no problems with file descriptors accidentally leaking into the cell.
PIDFD_CMD_START
This command sets the process running once all of the necessary parameters have been configured. After that, it is no longer an embryo, and pidfd_configure() can no longer be used with it.

The first process to be started within the cell becomes the init process for the cell; if it dies, the cell dies with it. It is possible to inject other processes into a running cell using this API, so the owner can, for example, start a shell within the cell if need be. But that must be done by creating a new process; existing processes are forbidden from crossing that boundary.

Other details

A lot of other restrictions at the cell boundary exist as well. Every process within the cell runs with the "no new privileges" flag set, so it cannot gain new capabilities. It is not possible to send open file descriptors across the boundary (in either direction) using Unix-domain sockets. Cells cannot share a control group with any other processes. And so on; the purpose is to make the containment of cells as tight and controlled as it can be.

There are a lot of details to this proposal that have not been covered here; it also contains a long list of open issues and shortcomings. As Bacik noted, the purpose is not to provide a complete implementation; instead, it "exists so that there is code to argue about". Readers wanting to know more should read through his entire proposal. The code exists in a GitHub branch; it contains a design document that covers much of what was discussed here and more as well.

So far, there has been little discussion of this proposal, perhaps because it was only posted to the linux-fsdevel mailing list. Nonetheless, it has evolved somewhat since the first version was posted in mid-October. This is not a small proposal, and it is trying to make changes that have proved controversial in the past, so it is not hard to imagine that discussion will eventually happen. At the far end of it, though, the kernel might just have the container abstraction that its community has resisted for so long.

Index entries for this article
KernelContainers


to post comments

"Cell" vs. "Jails"

Posted Oct 29, 2026 14:53 UTC (Thu) by NightMonkey (subscriber, #23051) [Link] (5 responses)

What is the metaphor behind the word 'cell'? A 'jail cell' or a 'biological cell'? And if it is the former, are we finally getting FreeBSD jails but in a very roundabout way? ;) Thanks for this article, and interesting to read about this idea.

"Cell" vs. "Jails"

Posted Oct 29, 2026 18:41 UTC (Thu) by rgmoore (✭ supporter ✭, #75) [Link] (3 responses)

A 'jail cell' or a 'biological cell'?

Those aren't the only options, of course. Maybe it's a monk's cell, a battery cell, a mobile phone cell, or a Communist Party cell. Etymologically, these all come from the same root, Latin "cella" meaning room, implying that the basic concept is encapsulation. The goal is to wall an area of the OS off from everything else so it can only affect or be affected by the rest of the system through whatever openings you deliberately give it. Maybe the goal is to contain a prisoner in solitary confinement, or maybe it's to protect the solitude of a monk who wants to engage in peaceful contemplation.

"Cell" vs. "Jails"

Posted Oct 29, 2026 21:16 UTC (Thu) by somlo (subscriber, #92421) [Link] (2 responses)

> The goal is to wall an area of the OS off from everything else so it can only affect or be affected by the rest of the system through whatever openings you deliberately give it.

Interestingly enough, that was what a *process* was for, back when "multitasking" became a thing in operating systems... :)

"Cell" vs. "Jails"

Posted Oct 30, 2026 7:09 UTC (Fri) by lutchann (subscriber, #8872) [Link] (1 responses)

>> The goal is to wall an area of the OS off from everything else so it can only affect or be affected by the rest of the system through whatever openings you deliberately give it.

> Interestingly enough, that was what a *process* was for, back when "multitasking" became a thing in operating systems... :)

Sure, and then when processes needed to interact, we created users, and when that wasn't powerful enough, we created virtual machines... (Or in a different order of appearance depending on whether you learned computing in academia or the corporate world.) We keep building walls between execution contexts, then poking holes in those walls, then building new, more sophisticated walls.

As always, there's an xkcd. https://xkcd.com/2044/

"Cell" vs. "Jails"

Posted Oct 30, 2026 8:48 UTC (Fri) by khim (subscriber, #9252) [Link]

Sure, and then when processes needed to interact, we created users

Users existed before there were any processes, though.

and when that wasn't powerful enough, we created virtual machines…

That's where it should have all stopped, but, of course, the architectures where things work like that lost and then we have started building Goldberg machines to compensate.

"Cell" vs. "Jails"

Posted Oct 30, 2026 12:04 UTC (Fri) by valadas (subscriber, #183860) [Link]

I think it's fair to assume it comes from a jail cell because it calls the processes in the cell "inmate" processes.

Mixed feelings

Posted Oct 29, 2026 15:38 UTC (Thu) by jrtc27 (subscriber, #107748) [Link]

Whilst I am happy to see Linux growing up and gaining a FreeBSD jail-like abstraction rather than the DIY mishmash approach it has required for many years, I am disappointed to see that the design document is entirely slop in style.

Adopting APIs from elsewhere?

Posted Oct 29, 2026 16:09 UTC (Thu) by calvin (subscriber, #168398) [Link]

Is there a reason why they're doing their own API rather than cloning i.e. FreeBSD's jail APIs, or at least mentioning prior art? I haven't dug back in the archives to see why.

System call heavy design

Posted Oct 29, 2026 16:24 UTC (Thu) by stefanha (subscriber, #55072) [Link] (7 responses)

The configure syscalls set one key/value pair at a time. That means a bunch of syscalls are required to set up a cell and pidfd. It would be nice to avoid this so that large numbers of processes and containers can be created without spending CPU cycles going back and forth between the kernel and userspace so often.

It may not seem like a problem now, but an API design is hard to change later on. An array of KV pairs per configure syscall maybe?

System call heavy design

Posted Oct 29, 2026 16:56 UTC (Thu) by kleptog (subscriber, #1183) [Link] (4 responses)

Something like io_uring, or dare I say it, BPF?

System call heavy design

Posted Oct 29, 2026 21:57 UTC (Thu) by jrtc27 (subscriber, #107748) [Link] (3 responses)

At what point does Linux give up and rename io_uring as syscall2 in recognition of it being the new system call API that obsoletes the traditional one? :)

System call heavy design

Posted Oct 30, 2026 0:54 UTC (Fri) by aviallon (subscriber, #157205) [Link] (2 responses)

How about asyscall or syscall_ring. Or sys_ring even.

System call heavy design

Posted Oct 30, 2026 10:34 UTC (Fri) by paulj (subscriber, #341) [Link] (1 responses)

Or perhaps aioctl or ioctl_ring?

System call heavy design

Posted Nov 2, 2026 9:07 UTC (Mon) by aviallon (subscriber, #157205) [Link]

Why restricting yourself to I/O only? Nothing would prevent adding other kinds of syscalls later, I believe?

System call heavy design

Posted Oct 29, 2026 20:34 UTC (Thu) by wahern (subscriber, #37304) [Link] (1 responses)

Using string keys and value references doesn't sound like a great idea, especially if you care about not having to bounce between kernel and user memory when reading KV pairs. Also creates another gaping seccomp hole.

String keys in particular doesn't buy you anything. It *feels* like a good abstraction, but it creates all the same kernel API and ABI dependencies; the only thing it buys you is complexity, opaqueness, and false sense of FFI simplicity.

System call heavy design

Posted Oct 29, 2026 21:09 UTC (Thu) by roc (subscriber, #30627) [Link]

> String keys in particular doesn't buy you anything. It *feels* like a good abstraction, but it creates all the same kernel API and ABI dependencies; the only thing it buys you is complexity, opaqueness, and false sense of FFI simplicity.

Well said! This is a classic trap that people fall into over and over again when designing APIs.

Bikeshedding

Posted Oct 29, 2026 17:27 UTC (Thu) by Cyberax (✭ supporter ✭, #52523) [Link]

CELL_SELF is -10005. That's kinda ugly, but I guess you'll need to support PIDFDs eventually for the `parent` argument.

Maybe explicitly add the "whence" flags indicating what type of parent you're using?

NIH & ugly as hell

Posted Oct 29, 2026 19:46 UTC (Thu) by rbranco (subscriber, #129813) [Link]

Just port FreeBSD Jails. Podman runs fine on those.

https://man.freebsd.org/cgi/man.cgi?sektion=2&query=jail

I don’t see the point.

Posted Oct 30, 2026 2:59 UTC (Fri) by eatnumber1 (subscriber, #136670) [Link] (1 responses)

Unless the author intends to remove the lower level primitives that make up a cell from the kernel, I fail to see any value in this proposal. The bugs will remain and the kernel’s syscall interface only grows, not shrinks.

Furthermore the implied assertion that each feature (namespaces, groups, etc) are not useful on their own is also obviously false.

I fail to see why containers shouldn’t be a user space concept assembled by a well tested common library everyone uses.

I don’t see the point.

Posted Oct 30, 2026 7:11 UTC (Fri) by k3ninho (subscriber, #50375) [Link]

I fail to see why containers shouldn’t be a user space concept assembled by a well tested common library everyone uses.

If the primitives subvert the library so that you can do an end-run around the 'safe defaults' tooling and undermine the security and task isolation of containers, I see a benefit to having one zones/jails/cells mechanism provided by the Kernel that shuts down this gap.

Maybe the library or these cells should have containers marked "managed by Kernel" so that the existing tools refuse to interfere with them.

K3n.

Cell in cell?

Posted Oct 30, 2026 8:38 UTC (Fri) by cyperpunks (subscriber, #39406) [Link] (2 responses)

Will this design support nested cells?

Cell in cell?

Posted Oct 30, 2026 12:51 UTC (Fri) by corbet (editor, #1) [Link]

The current implementation does not support nesting; I suspect that would be necessary in the long run, though.

Cell in cell?

Posted Oct 30, 2026 16:58 UTC (Fri) by josefbacik (subscriber, #90083) [Link]

Yes, it'll be a slot just like everything else. You can turn it on and create nested cells that cannot get anything more than the cell creating it. You can turn it off and then nesting is disallowed. I don't think I have it in the Git tree right now but it's in my local branch that I'm working on.

lack of fd-passing seems very restrictive

Posted Oct 31, 2026 11:17 UTC (Sat) by smcv (subscriber, #53363) [Link]

> It is not possible to send open file descriptors across the boundary (in either direction) using Unix-domain sockets

This seems like a rather heavy restriction: fd-passing across the boundary isn't needed for the use-case where what you want is "a virtual machine, but cheaper", like a typical use of Docker or Incus; but in less-restrictive container use-cases like Flatpak, Toolbox or the sandboxed helpers used by e.g. web browsers, there are various protocols (Wayland, Pipewire, D-Bus services) that want to do capability-based security across the container boundary by fd-passing a memfd, or the end of a pipe, or some similar resource (with the presence/availability of the fd encapsulating permission to do whatever it represents). Having a way for the container manager to opt-in or opt-out from allowing fd-passing seems maybe better than having it hard-wired?

One of the effects of the current piecemeal approach to containers is that it's difficult to look at a process and ask: is this in a container? if yes, which container technology, and which instance ID does it have? - so it doesn't seem ideal if this new unifying feature is only usable at the most-strongly-isolated end of the container spectrum, with less-strongly-isolated containers being officially "not actually a container" from its point of view.

OpenVZ had it figured out in 2005

Posted Oct 31, 2026 15:41 UTC (Sat) by dowdle (subscriber, #659) [Link] (1 responses)

I remember using OpenVZ for more than 10 years. It was fantastic. Of course, they developed it entirely out-of-tree and it was a gigantic patch to primarily RHEL kernels... and there was no way that it would ever be accepted in the mainline kernel. Unfortunately Docker came along in 2013 and kinda spoiled the scene and everyone seemed to think "application" containers were the way to go... and we've been off on that tangent ever since. Virtuozzo has changed hands a few times I'm not sure who they are today but they are still plugging away at it. Oh, can you tell? I'm really opinionated about system containers being better... and yes I know you an do system containers with Docker (although I prefer podman)... but it just isn't the same.

OpenVZ had it figured out in 2005

Posted Oct 31, 2026 16:11 UTC (Sat) by intelfx (subscriber, #130118) [Link]

System containers require good supervision to be viable. When Docker came along, there was no good ubiquitous system-level supervisor, so Docker took on that role by association (which is only possible if you run application containers).

Now that we have systemd in ubiquity, system-level containers in form of LXC/LXD/Incus/nspawn are absolutely sound, viable, and well-developed.


Copyright © 2026, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds