A whole Linux machine inside a Cloudflare Durable Object.
Each Durable Object runs unkernel (a real Linux 7.x
kernel compiled to WebAssembly) and boots Alpine Linux. The root disk lives in the Durable
Object's SQLite, so the machine keeps its files across restarts. Guest TCP goes out through
Cloudflare's connect() sockets, so apk add, curl and wget work.
One Durable Object per name gives you one machine per name: box=alice, box=ci-1234,
box=agent-7.
demo@cloudflare-do $ uname -a
Linux unkernel 7.3.4+ ... aarch64 Linux [250 ms]
demo@cloudflare-do $ sudo apk add -q jq curl && echo installed
installed [5.7 s]
demo@cloudflare-do $ echo '{"n":[1,2,3]}' | jq '.n|add'
6 [291 ms]
demo@cloudflare-do $ curl -sI https://github.com | head -1
HTTP/2 200 [1.2 s]
Inspired by postgres-please, which runs Postgres (pglite) in a Durable Object with SQLite as its disk. This does the same one level down.
| Bundle (kernel + Alpine image) | 8.8 MB gzipped (fits the paid plan's 10 MB limit) |
| New machine, end to end (cold start, disk setup, boot, first command) | 1.4 to 2.1 s |
| Command on a running machine | about 0.2 to 0.5 s round trip |
| Restart from a saved disk | under 1 s, files intact |
| Guest RAM | 64 MiB default, up to 128 MiB tested |
- A throwaway Linux box per agent, test run or user, created by naming it.
- A persistent scratch machine that keeps installed packages and files between sessions.
- Run ordinary CLI tools (jq, curl, wget, the busybox set) next to your Worker without containers.
- Restart a machine with
?reset=1: it reboots from its SQLite disk with your files intact.
- Kernel: unkernel runs Linux as wasm with a real MMU and emulates aarch64 user programs. Workers block compiling wasm at runtime, so its JIT is off and user code runs on its interpreter.
- Disk: a small
BlockDevicestores 4 KiB blocks as rows in the Durable Object's SQLite. Alpine's read-only base image is bundled; your changes go to the SQLite disk through overlayfs. - Network (
src/net.mjs): each guest TCP connection becomes aconnect()socket. Workers have no UDP, so DNS answers with placeholder addresses (198.18.0.0/15) and the socket is opened by hostname. Cloudflare refuses raw TCP to port 80, so plain HTTP is parsed and sent throughfetch()instead.
- Clock. In workerd a
setTimeoutcan fire beforeperformance.now()reaches its deadline. The guest's timers then never expire (sleep 1hangs).scripts/setup.mjspatches the SDK to move its virtual clock forward when a timer fires early. - Disk writes. Writing each block to SQLite from inside the kernel's block path froze the
kernel (most likely the Durable Object's input gate). Writes go to a dirty map and are saved
once a second in one
transactionSync.
- CPU. Heavy work in one request can hit Cloudflare's CPU limit, which resets the Durable
Object (the disk survives). Installing from Alpine's
communityrepo did this;mainis fine. - Clock. Cloudflare only advances time on I/O, so guest timestamps during busy CPU work are off.
- Network. No UDP, ICMP, IPv6 or inbound connections. Hosts behind Cloudflare's own proxy can't be reached over HTTPS (Cloudflare blocks sockets to them).
- Durability. Up to 1 s of guest writes can be lost if the Durable Object dies.
- Cost. A running machine keeps its Durable Object in memory, billed for duration. No hibernation yet.
- Shared isolates. Several Durable Objects can share one isolate, so all VM state is kept on the instance, not in module scope.
Needs Node 24+ and a Cloudflare account on the paid Workers plan.
npm install # also fetches Alpine and patches the SDK
npx wrangler secret put BOX_TOKEN # pick a long random token
npm run deploy
Then open a shell (the token can also go in a .box_token file):
BASE=https://linux-please.<your-subdomain>.workers.dev BOX_TOKEN=... node console.mjs mybox
BASE=... BOX_TOKEN=... node console.mjs demo --demo # a short tour first
Or one command at a time:
curl -G -H "Authorization: Bearer $BOX_TOKEN" "$BASE/run" \
--data-urlencode box=mybox --data-urlencode "cmd=cat /etc/os-release"
Every request needs the token: a box is a real machine with outbound internet on your account.
For local development, put BOX_TOKEN=... in .dev.vars and run npm run dev.
- unkernel: the kernel (GPL-2.0) and SDK (MIT).
- Alpine Linux: the base image, downloaded at install time.
- postgres-please for the idea.
The code in this repository is MIT licensed.