一个快速、无根的沙箱和虚拟资源运行时。在真实容器中运行任何工作负载,包括
# 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# 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# 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 VMRuns 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.
A rootless container runtime in one static binary. No daemon.
kern box --image alpine -- sh # full isolation
kern run --memory 256m --cpus 0.5 -- ./job # limits only, host still visible
kern compose up -dpull, build from a Containerfile or Dockerfile,
commit, push, save/load. A box from an image starts in ~3.4 ms.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.
--security-profile untrusted, is the whole hardened bundle.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.mdkern 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.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.
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.
curl -fsSL https://raw.githubusercontent.com/getkern/kern/main/install.sh | shOne 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:
cargo install --git https://github.com/getkern/kern getkern --lockedDebian 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.
kern-sandbox (PyPI,
npm) needs the binary above, so install that first:
pip install kern-sandbox
npm install kern-sandboxBoth 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:
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.
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/.
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/.
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.faultEvery 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.
{ "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/.
docker-compose.yml, unchangedOne file, one command. kern reads its own format, and it reads the docker-compose.yml you already
have, unchanged.
# 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"]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 boxkern 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:
systemd-run --user --scope bash # then run kern in that shellkern 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.
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).
# ~/.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,或尚未同步最近议题。