# Images (https://kumoba.dev/images)

An image is a raw ext4 disk. kumobad boots every image in `~/.kumoba/images`, or the ones `KUMOBAD_IMAGES` lists, so you can build your own.

## The default image [#the-default-image]

`images/default/Dockerfile` builds a Debian 13 system with:

- `bash`, `git`, `curl`, `jq`, `sudo` (passwordless for the `kumoba` user)
- Python 3 with `pip` and `venv`. `pip install` works directly, as root or as `kumoba`
- Node.js 26.14.0 LTS with `npm` and `npx`, from the official Node.js binaries in `/usr/local`, so the [TypeScript SDK](/typescript) and the npm CLI run inside a sandbox
- Chromium, fonts for Latin and CJK text
- An xfce desktop on Xvfb with kumoba's live view and noVNC, plus `scrot`, `xdotool` and AT-SPI for the `desktop` API
- The `kumoba` user (uid 1000) and a `/workspace` it owns

Build it with Docker:

```sh
scripts/build-image.sh default          # → .local/images/default.raw (16 GB sparse)
DISK_SIZE=32G scripts/build-image.sh default
```

The script builds for the host's architecture and needs no root privileges, only Docker with buildx. BuildKit streams the finished filesystem straight into `mkfs.ext4`, so the image never enters Docker's image store and dockerd's memory stays far below the image size, also for a multi-GB image on a small CI runner.

## The test image [#the-test-image]

`scripts/build-test-image.sh` builds a small Alpine image without Docker. The test suites use it, and the installer offers it as `KUMOBA_IMAGE=test`.

## Writing your own image [#writing-your-own-image]

Any Linux root filesystem works as long as:

1. `/usr/local/bin/kumoba-guest` exists and is executable. The worker runs it as the VM's init process; it writes `/etc/hosts`, creates `/workspace`, then serves the host over vsock. Build it with `scripts/build.sh` (static musl binary in `.local/bin/kumoba-guest`).
2. `/bin/sh` exists. The SDK runs string commands through it.
3. Programs that should reach the network honour `HTTP_PROXY`/`HTTPS_PROXY` or Chromium's managed proxy policy. The agent sets the proxy variables for every command it runs; `images/default/rootfs/etc/profile.d/kumoba-proxy.sh` covers interactive shells.
4. For `sandbox.desktop`: `images/default/rootfs/usr/local/bin/kumoba-desktop` and `kumoba-browse`, plus `xvfb`, an xfce session, `x11vnc`, `websockify` with `novnc`, `scrot`, `xdotool`, `python3-pil` and `python3-pyatspi`. For the live view, also `/usr/local/bin/kumoba-view` (static musl binary in `.local/bin/kumoba-view`, built by the same script). Without it the live view is noVNC.

Put your Dockerfile and any `rootfs/` overlay in `images/<name>/` and run `scripts/build-image.sh <name>`. The script copies `kumoba-guest` and `kumoba-view` into the build context for you.

## From an existing image [#from-an-existing-image]

If you already maintain a container image for your sandboxes, turn it into a kumoba image with one command:

```sh
scripts/build-image.sh --from ghcr.io/acme/sandbox:1.4 acme   # → .local/images/acme.raw
```

The script adds `kumoba-guest`, `kumoba-view` and the `kumoba-desktop` and `kumoba-browse` helpers to `/usr/local/bin` on top of that image, plus the proxy settings of the default image's overlay for interactive shells (`/etc/profile.d/kumoba-proxy.sh`) and Chromium (`/etc/chromium/policies/managed/kumoba-proxy.json`), and the Chromium flag that lets `ui-tree` see it (`/etc/chromium.d/kumoba-accessibility`, read by Debian's `chromium` wrapper), and writes the result like any other image. It leaves the image's other files alone, so its own `/etc/pip.conf` or `/etc/hosts` stays; `kumoba-guest` adds the `sandbox` name to `/etc/hosts` at boot.

The image must have a variant for the host's architecture (`linux/arm64` on Apple silicon and ARM Linux, `linux/amd64` on x86_64). The reference can be any image Docker can pull, or one in the local image store when the builder uses the docker driver (the default unless you ran `docker buildx use`). Docker uses a tag it already has, so run `docker pull` first to pick up a newer one. The rules above still apply: the image needs `/bin/sh`, and the desktop packages for `sandbox.desktop`. Only the filesystem is used: `kumoba-guest` is the VM's init, so the image's `ENTRYPOINT`, `CMD`, `USER` and `ENV` don't apply.

## Sizing [#sizing]

An image file is sparse: it shows the guest's full disk size but uses only what the image contains, about 1.5 GB for `default`. kumobad keeps one read-only copy of each image version in its state directory: a clone on APFS, XFS and Btrfs, and a real copy of the used blocks, made once, on ext4 and other Linux filesystems that can't clone files. Each new sandbox is a copy-on-write layer over that copy on a Mac and on ext4, or a clone of it on XFS and Btrfs, so it costs only what it writes. `KUMOBAD_DISK_MODE=copy` gives every sandbox a full copy instead. See [Disks](/architecture#disks).