Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
kern

kern

> 云原生
Free

a fast, rootless sandbox and virtual resource runtime. Run any workload in a real container, includi

394 stars0 likes6 views
WebsiteGitHub

About

a fast, rootless sandbox and virtual resource runtime. Run any workload in a real container, includi

bash
# install the release binary (static, checksum-verified by the script)
curl -fsSL https://raw.githubusercontent.com/getkern/kern/main/install.sh | sh

# a throwaway shell in a real OCI image: rootless, kernel-enforced, a few ms
kern box dev --image alpine -it -- sh
powershell
# Windows: the same binary under WSL2, and the script sets WSL2 up for you
irm https://raw.githubusercontent.com/getkern/kern/main/install.ps1 | iex
bash
# macOS, two steps: a Linux VM, then kern inside it
brew install colima && colima start && colima ssh
curl -fsSL https://raw.githubusercontent.com/getkern/kern/main/install.sh | sh   # inside the VM

Runs on Linux and ARM boards directly, on Windows through WSL2 and on a Mac through colima, Lima or OrbStack: the same binary and the same CLI under a Linux kernel. Install.


What kern is

A rootless container runtime in one static binary. No daemon.

bash
kern box --image alpine -- sh              # full isolation
kern run --memory 256m --cpus 0.5 -- ./job # limits only, host still visible
kern compose up -d
  • A real container. Real OCI images: pull, build from a Containerfile or Dockerfile, commit, push, save/load. A box from an image starts in ~3.4 ms.
  • Run LLM-generated code in a sandbox, one per call. The snippet a model just wrote, the command an agent just decided to run, a notebook cell, a CI step. kern starts a box, runs it, deletes it, fast enough that per-call isolation is the default. Network off unless you ask, memory and PID caps the kernel enforces, capabilities dropped, seccomp deny-by-default, timeout applied from the outside.

Typed faults, not stack archaeology. Timeout, OOM-kill, blocked syscall, missing command: each returned next to stdout and the exit code. Branch on it and keep going.

One binary, no daemon. Wire it from Python, Node, LangChain, or any MCP client below. And what it is not, because the boundary is the Linux kernel.

  • Rootless, always. User, PID, mount, network, UTS and IPC namespaces, an overlay or read-only root pivoted in, a deny-by-default seccomp allowlist and cgroup v2 limits. One flag, --security-profile untrusted, is the whole hardened bundle.
  • Resource profiles, not just isolation. CPU (vcpu:), memory, disk (vdisk:) and devices (vgpio:), declared once in a kern.toml and attached by name. kern run applies the same caps to a process on the host, with no sandbox at all, plus --landlock-rw to confine that process's writes with the kernel's own LSM. docs/RESOURCES.md
  • Stacks, in kern's own format or in the one you already have. kern compose up takes a stack.toml ([box.NAME] tables, with the resource profiles above) or a docker-compose.yml, with no conversion step. One stack to one pod, services reaching each other by name.
  • The tools around them. ps, logs, exec, stats, inspect, wait, top (a live TUI), doctor. The Python binding also plugs into LangChain twice: as a code tool, and as an execution policy for its shell middleware.

Its entire Rust dependency tree is libc: JSON and OCI manifests are parsed by hand, and pull shells out to the curl and tar already on the machine rather than linking a TLS stack.

Install

The binary

A box is made of Linux kernel features, so kern runs where there is a Linux kernel: Linux and ARM boards (Raspberry Pi · Jetson · Arduino UNO Q) directly, Windows through WSL2 with a pre-baked rootfs and an installer that sets WSL2 up for you, and a Mac inside a Linux VM (colima, Lima, OrbStack, UTM), where it is the ordinary Linux kern: same binary, same CLI, same behaviour as your CI box.

bash
curl -fsSL https://raw.githubusercontent.com/getkern/kern/main/install.sh | sh

One static file, no toolchain. The script picks x86_64 or aarch64, installs to ~/.local/bin, and refuses a download whose SHA256 does not match. From source instead, the whole dependency tree is one crate:

bash
cargo install --git https://github.com/getkern/kern getkern --locked

Debian and Ubuntu, Fedora, the RHEL family (Rocky, CentOS Stream), openSUSE, WSL2, and ARM boards: any distribution with unprivileged user namespaces and cgroup v2. Each release runs the full suite on those, in real VMs and on the boards, before it ships.

docs/INSTALL.md has the rest: verifying the checksum by hand, KERN_INSTALL_DIR, the Windows and Mac guests step by step, and what the resource caps do on a default VM.

The SDK, to call kern from Python or Node

kern-sandbox (PyPI, npm) needs the binary above, so install that first:

bash
pip install kern-sandbox
npm  install kern-sandbox

Both packages are the wrapper alone: they find kern on your PATH, or wherever $KERN_BIN points. The two are released on their own clocks, so check what you have when a call does something the changelog says it should not:

bash
kern --version
python3 -c "import kern_sandbox; print(kern_sandbox.__version__)"

What it is for is further down; the changelog names the release each fix landed in.

Quickstart

bash
kern box dev --image alpine -it -- sh                  # a shell in a real OCI image
kern box svc --image nginx:alpine -d -p 8080:80        # a service, published
kern box job --image python:3.12-slim --security-profile untrusted -- python3 /w/x.py
kern compose stack.toml up                             # a whole stack, one command

--security-profile untrusted is the seccomp allowlist plus --cap-drop ALL plus --read-only, in one flag. kern ps and kern top show what is running; every verb that lists or inspects also answers --json, so nothing has to parse a table. One runnable example per thing kern does: examples/.

Run an agent's code: Python, Node, LangChain, MCP, pi

The bindings are how your program calls kern. The code inside the box can be in any language, because the box is an OCI image: Python, Node, Go and Rust all run with the same command and a different --image, and so does anything else that ships one.

An agent needs somewhere to run what the model just wrote. kern-sandbox is that place: a thin, dependency-free wrapper over the kern binary, called from your own program. Installed above; the API is in bindings/python/ and bindings/node/.

python
from kern_sandbox import run_code

r = run_code("import platform; print(platform.python_version())")
print(r.stdout)          # ran in a fresh box; a timeout / OOM / blocked escape is data on r.fault

Every call is a fresh isolated box: network off, memory and pid caps, capabilities dropped, output bounded, and a timeout the binding enforces itself. A timeout, an OOM-kill or a blocked syscall comes back as a typed fault on the result rather than as an exception. code_stderr is that result's stderr without kern's own notes, which is what belongs in a context window.

It also ships kern-mcp, a dependency-free stdio server that gives Claude Desktop or Cursor a local code interpreter, and the server is stdio, so the same one line points a client at a box on another machine.

json
{ "mcpServers": { "kern": { "command": "kern-mcp" } } }

The rest is on the pages that own it, none of it repeated here: the full API, the rich-result capture, prewarming and the LangChain integration in bindings/python/README.md and bindings/node/README.md; every KERN_MCP_* variable and the remote form in docs/MCP.md; and, for the pi coding agent, kern-pi routing its bash, read, write, edit, ls, grep and find into a box, with a README that states which half is the kernel's boundary and which is a path check, in integrations/pi/.

Run a whole stack: your docker-compose.yml, unchanged

One file, one command. kern reads its own format, and it reads the docker-compose.yml you already have, unchanged.

toml
# stack.toml - one table per service, keys spelled like the `kern box` flags
[box.db]
image = "postgres:alpine"
env   = ["POSTGRES_PASSWORD=secret", "POSTGRES_DB=app"]

[box.web]
image      = "adminer"
ports      = ["8080:8080"]
depends_on = ["db"]
bash
kern compose stack.toml up            # or point it at your compose.yaml instead
kern compose stack.toml ps            # what is running, and what each service publishes
kern compose stack.toml port web 8080 # the host address serving that port, read from the running box

kern compose watch is the fourth one, left out of the block above because it needs a service with a build: context and the file here has none: pointed at a stack that builds, it rebuilds and restarts that one service when its context changes.

Both official images start, web reaches db by service name, and the port is published. A compose file can also name kern's own things in the spec's extension namespace (x-kern-vcpu, x-kern-security-profile) and still run anywhere else unchanged, because the spec has every runtime ignore an x- field. A typo inside one is reported rather than dropped.

Each service gets its own network namespace, and they meet on a bridge, which is the arrangement a Docker user already has: a service's 127.0.0.1 is its own, two services may listen on the same container port, and peers reach each other by name at their addresses. A single-service stack keeps one namespace, because there is nobody to separate it from. When networks: leave two services with nothing in common, kern honours that separation with a namespace per service and no bridge between them, announcing what it costs (a relay hop between the peers that do share a network). --pod forces one shared namespace, which is faster and refuses a file it cannot express rather than running it with the separation dropped; --bridge and --no-pod ask for the other two explicitly.

Official images that drop to a non-root user want uidmap and an /etc/subuid line, and outbound pulls want pasta; kern doctor names either if it is missing. This is the local dev loop, not a production orchestrator. docs/DOCKER-COMPAT.md

On a server you reached over ssh, run kern inside a scope once. An ordinary ssh session sits outside the systemd user manager on every distribution we measured, and a box's caps live in a cgroup that session cannot write into: the stack comes up and is capped correctly, but kern compose … exec refuses, because entering the box would step outside those caps. One line fixes it for the whole session and keeps the caps enforced:

bash
systemd-run --user --scope bash     # then run kern in that shell

kern doctor reports which cap path a host takes. On Ubuntu 23.10 and newer there is one more thing to do first, once, with root: see docs/INSTALL.md.

Resource profiles

A slice is declared once in ~/.config/kern/kern.toml and attached by name, to a sandboxed box or a bare process, with the same token. Three kinds: vcpu: (CPU and memory), vdisk: (a size-capped scratch disk) and vgpio: (device nodes).

toml
# ~/.config/kern/kern.toml - declared once, attached by name
[[cpu]]                     # the host budget a slice is carved from
id    = "cpu:0"
cores = 8.0

[[vcpu]]                    # 1.5 cores and 512 MiB  ->  attach as  vcpu:heavy
name    = "heavy"
backend = "cpu:0"
cpus    = 1.5
memory  = "512m"

[[

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

cgroupscode-executioncontainer-runtime

No comments yet. Be the first to share.

> Details

PublishedSep 9, 2026
UpdatedSep 17, 2026
Category云原生
PricingFree

> Related tools

K
Kubernetes
容器编排事实标准
H
Helm
Kubernetes 包管理器
S
seaweedfs
SeaweedFS is a distributed storage system for object storage (S3), file systems, and Iceberg tables,