The runtime and the pod
createRuntime() boots one Linux VM compiled to WebAssembly; rt.run() starts containers in it as namespaces and cgroups of one kernel.
createRuntime() boots one VM: the Linux kernel of
unkernel, compiled to WebAssembly, with a BusyBox user
space of its own. rt.run() starts containers in it: each is a set of namespaces (mount, PID,
UTS, IPC) and a cgroup in that one kernel, with the image's file system as its root.
#One network, like a pod
All containers of a runtime share the VM's network namespace, as the containers of a Kubernetes
pod do: they reach each other as localhost, and by name (each container's name is in every
container's /etc/hosts). A port can be held by one container only: a second one gets
ERR_PORT_IN_USE before it starts.
The guest has no network by default. On Node, publishPort() (untainer run -p) serves a
container's port on the host, and net: directBackend() gives the guest outgoing connections;
see Network.
#Init, users and signals
- Every container runs a small init as PID 1 by default (unlike Docker), so that a command
without a SIGTERM handler still stops on
stop();init: falseturns it off. - The command runs as the image's user, looked up in the container's own
/etc/passwd; a user that does not exist ends the container with exit code 125, never with root. stop()sends SIGTERM, then SIGKILL after 10 s.
#Volumes
| Volume | What |
|---|---|
tmpfsVolume() | an empty tmpfs, per container |
memoryVolume() | files in the host process's memory, shared by the containers given it |
hostVolume(dir) (Node) | a directory of the host |
diskVolume(name) | a directory on the runtime's persistent ext4 disk (createRuntime({ disk })) |
#Services
rt.up() and untainer up start a set of services from a compose file's subset (image,
environment, ports, volumes, depends_on, command), each once the ones it depends on are ready.
#Where the VM runs
In a worker by default (a Web Worker in a browser, a worker thread on Node), so a busy guest
never blocks the page or the process. worker: false runs it on the calling thread instead.
One case chooses for you: a network policy is code of the calling thread, so
a runtime given one runs its VM there too. The details and their cost are in
docs/runtime.md, "Where the VM runs".
The guest's user space is aarch64: images must have a linux/arm64 variant, as the official
Docker Hub images do.