Skip to content

Command reference ​

Every cairn command and subcommand: what it does, the flags you will use, an example, and what its exit status means. Run cairn <command> --help for the same flags straight from the binary. This page groups the rarely used ones.

Most people use six commands: deploy, status, ps, stop, start and destroy. Read those sections first; the rest is for networks, volumes, kernels, agents and the host admin.

Contents ​

Global behaviour ​

text
cairn [--json] [-h|--help] [-V|--version] <command> ...
  • --json prints one JSON document on stdout instead of text. Every command accepts it, before or after the subcommand. Under --json an error is also JSON, with a code field a script can branch on. A usage error under --json is JSON with exit status 2.
  • Output on a terminal and in a pipe differ. A terminal gets colour and a live progress line; a pipe, a file or --json gets plain text, the same words every time. NO_COLOR=1, CLICOLOR_FORCE=1 and CAIRN_PROGRESS=plain change this; see troubleshooting.
  • Apps are named by the app key of their cairn.toml: 1 to 48 of a-z, 0-9 and hyphens. Commands that take <APP> do not need the project directory; you can run them from anywhere.
  • Where state lives. Commands read and write ~/.cairn (an installed cairn always uses it); see configuration.
  • Commands that create things (deploy, start, run, net create, net up, and so on) first check that your account may run VMs here, and refuse with the fix if not. Run cairn access to see why.

Exit status in general: 0 success, 1 the command failed, 2 a usage error (bad flag or argument). exec, console and run pass the program's own status through and use 125 for "refused"; they are described in their sections.

deploy ​

Build or pull the image, build a new machine, stop the running one, start the new one and wait until it is ready. If the new one fails, the deploy rolls back and the previous deployment is started again. A deploy first settles an earlier attempt of the app that did not finish (see lifecycle).

text
cairn deploy [OPTIONS] [DIR]

DIR is the project directory holding cairn.toml (default .). The manifest is described in manifest; the flow in lifecycle.

sh
cairn deploy --dry-run          # show what would be deployed, change nothing
cairn deploy                    # deploy the project in the current directory
cairn deploy ./shop --pull --wait-timeout 3m
cairn deploy --cpus 2 --memory 1gb --allow pypi.org,files.pythonhosted.org

Common flags. A flag, when given, overrides the same key in cairn.toml.

FlagMeaning
--dry-runPrint the resolved settings (including which variables the file reads, never their values) and deploy nothing.
--pullFetch the image again even if cached.
--wait-timeout <T>Readiness deadline, 1s to 1h (default 60s). A failure keeps the previous deployment.
--no-checksSkip waiting for readiness. Health checks still run afterwards.
--cpus <N>vCPUs, 1 to 32.
--memory <SIZE>Guest memory, at least 128mb.
--rootfs-size <SIZE>Root filesystem size, at least 64mb.
--env-file <PATH>A variable file for ${NAME} templates in [env] and [build] args. Repeatable, read in order. When given, the project's .env is not read. See manifest.
--allow <ENTRY,...>The egress allowlist: names or a.b.c.d/len, comma-separated. --allow '' allows nothing.

Less common flags:

FlagMeaning
--network <NAME>Join this network instead of the app's own. Apps on one network reach each other as <app>.internal.
--network-mode <nat|off>NAT to the host, or no network device at all.
--dns <host|IP,...>host, or one to three resolvers, comma-separated.
--kernel-file <PATH>Boot this uncompressed x86_64 ELF vmlinux. Replaces kernel, kernel_file and kernel_sha256 in the file. See kernels.
--launcher <auto|systemd|direct>How the supervisor is started. auto (default) keeps the saved choice. See concepts.
--jail <require|off>Jail mode. off is available only here, never in a file, and is refused for an app with volumes.
--replace-allowlistAccepted for old scripts; does nothing.

Exit status: 0 deployed (even if a cleanup is left pending, which is reported); 1 failed; 130 interrupted with Ctrl+C. The first Ctrl+C cancels the deploy, which deletes the new machine or rolls back to the previous one; a Ctrl+C during that rollback is ignored. A second Ctrl+C exits at once: the attempt is recorded, and the next cairn deploy, start, stop or destroy of the app settles it.

The result's outcome says where the app is:

outcomeMeaning
deployedThe new release is current and everything was cleaned up.
deployed_cleanup_pendingThe new release is current; some cleanup is left and listed. The next deploy retries it.
previous_preservedFailed before the previous machine was stopped; it was not touched.
previous_runningRolled back; the previous machine runs (it would not stop, or it was started again and is ready).
previous_startingRolled back; the previous machine was started again and was not ready in time.
previous_stoppedRolled back; the previous machine is not running (it ended, or it was stopped before the deploy).
previous_heldRolled back and held: the new release may have changed the volumes. See volumes.
previous_unconfirmedRolled back; whether the previous machine runs could not be told.
left_for_next_commandThe attempt could not be settled (or a second Ctrl+C stopped it). The next cairn deploy, start, stop or destroy settles it; cairn stop works when the others refuse.

--json prints the deployment, including deploy.kernel and deploy.warnings. With --dry-run it prints the plan (for example vm.balloon).

status ​

Show one app: its state, health, restarts, network, volumes, kernel, and log paths.

text
cairn status [--json] <APP>
sh
cairn status shop
cairn status shop --json

Exit status 0 whenever it could answer, whatever the app's state. Use cairn ps to list all apps. See lifecycle for what each state means.

ps ​

List apps and their virtual machines: each app's current machine and, while a deploy rolls back, its new machine (ROLE new). Only machines the records name are listed; cairn doctor reports a Firecracker process of yours that no record names.

text
cairn ps [OPTIONS]
FlagMeaning
--appsOne row per app (its current machine) instead of one per machine.
--state <STATE>Filter by state, including held. Repeatable or comma-separated.
--health <WORD>Filter by health: healthy, starting, unhealthy, unknown or none. Repeatable or comma-separated.
-q, --quietPrint only row identifiers (app names with --apps).
--verboseAdd state details, warnings and health results.
sh
cairn ps
cairn ps --apps --state running,held
cairn ps --apps -q | xargs -n1 cairn status

A - in the HEALTH column means no verdict. --verbose and --quiet cannot be combined with --json (a JSON usage error, exit 2). Exit status: 0 when every app was read, whatever its state; 1 when something could not be read (the table is still printed).

start ​

Start the stopped machine of an app. The disk is preserved. It waits for startup, not for readiness.

text
cairn start [OPTIONS] <APP>
FlagMeaning
--wait <T>Startup deadline (default 250s). A timeout does not undo the start.
--releaseClear the app's hold first, then start the previous release on its volumes as they are. For an app held after a failed deploy; see volumes.
sh
cairn start shop
cairn start notes --release

Exit status 0 started, 1 failed, 130 interrupted with Ctrl+C while waiting. A held app refuses to start without --release.

start first settles an earlier deploy of the app that did not finish, then starts the app's current machine. Settling never starts anything by itself, so this is the command that brings an app back after a deploy was killed. If settling cannot finish, start refuses (Unsettled) and cairn stop <app> settles it.

stop ​

Stop an app's machine. Disks and network resources are kept for cairn start.

text
cairn stop [OPTIONS] <APP>
FlagMeaning
--timeout <T>Grace period before the machine is killed, at most 310s. Default 20s, or the manifest's kill_timeout plus 10s when that is longer.
--forceInterrupt attached cairn run sessions instead of refusing. Their unsynced work stays in the machine and its disk is kept.
sh
cairn stop shop
cairn stop shop --timeout 60s

Stopping a cairn run app syncs its folder first. stop and destroy first settle an earlier deploy of the app that did not finish. Exit status 0 stopped, 1 failed or incomplete (a recorded cleanup is unfinished), 130 interrupted with Ctrl+C while waiting.

destroy ​

Delete an app and its machines: disks and records. The network is left in place (see net destroy).

text
cairn destroy [OPTIONS] <APP>
FlagMeaning
--volumesAlso delete the app's volumes and their data. Without it they are kept and listed.
--timeout <T>Same as stop.
--forceInterrupt attached cairn run sessions.
--discardFor an app made by cairn run: delete whatever is only in its machine, instead of syncing it into the folder first (the command refuses if it cannot sync).
sh
cairn destroy shop
cairn destroy notes --volumes

Exit status 0 destroyed (kept volumes, which are listed, do not change it), 1 failed or incomplete (a machine could not be confirmed gone, or a volume could not be read or deleted), 130 interrupted with Ctrl+C while waiting.

pause ​

Freeze an app's machine in place. It keeps its memory and its network ports.

text
cairn pause [--json] <APP>

resume ​

Unfreeze a paused machine. Use cairn start for stopped machines.

text
cairn resume [--json] <APP>

Both ask the machine's supervisor and wait up to 5 s for its answer. Both refuse while a deploy of the app is under way or did not finish. resume also releases a machine that is frozen (a VMM stopped by a signal, or a unit frozen with systemctl --user freeze). See lifecycle.

Both exit 0 on success (and when already paused, or not paused), 1 on failure and 130 when interrupted with Ctrl+C while waiting.

exec ​

Run a command inside a running machine. There is no implicit shell: cairn exec app -- ls -la runs ls directly; use sh -c for shell syntax.

text
cairn exec [OPTIONS] <APP> [--] <COMMAND> [ARGS]...
FlagMeaning
-i, --interactiveForward stdin to the command. Without it the command sees EOF.
-t, --ttyAllocate a guest terminal. -it gives raw input and the ~. escape.
-u, --user <USER[:GROUP]>Guest user and optional group, name or ID (default: the workload's).
-w, --workdir <DIR>Absolute guest directory (default: the workload's).
-e, --env <KEY=VALUE>Set an environment variable. Repeatable.
--machine <ID>Pick a machine by ID (default: the current one).
sh
cairn exec shop -- ls -la
cairn exec -i shop -- cat < file
cairn exec -it shop -- sh
cairn exec shop -- sh -c 'df -h /data'

Flags after COMMAND belong to the command; put -- before a program whose name starts with -. The command runs with the workload's user, directory and environment unless you change them. ~. at the start of a line disconnects an interactive session; ~? shows help. Processes the session started end with the session.

Exit status:

StatusMeaning
the command's codepassed through unchanged
128 + Nthe command ended by signal N
125request refused (including a usage error); nothing ran
126the command could not run
127command not found
141the local output pipe closed
255unknown result, or cleanup incomplete

console ​

Open a shell in a running machine. It needs a terminal on stdin.

text
cairn console [OPTIONS] <APP>

Flags: --shell <PATH> (absolute shell path; no fallback when given), -u/--user, -w/--workdir, -e/--env and --machine, as for exec. Without --shell it tries an absolute $SHELL, then /bin/bash, /bin/sh, /bin/ash. Type ~. at the start of a line to disconnect.

sh
cairn console shop
cairn console shop --shell /bin/sh -u 1000

Exit status: the shell's code; 128 + N for a signal; 125 refused or no usable shell; 255 disconnected or cleanup incomplete.

run ​

Run an agent (by default Claude) in a microVM with the current folder's files, kept in sync with the folder. This section is a summary; the full guide is run.

text
cairn run [OPTIONS] [AGENT] [-- <ARGS>...]

AGENT is an alias from [run] in $CAIRN_HOME/providers, or an image (default claude). ARGS go to the agent after the image's ENTRYPOINT.

Session flags:

FlagMeaning
--shellA shell in the app instead of the agent.
-e, --env <KEY[=VALUE]>Set a variable for the session; KEY alone forwards the host's value. Repeatable.
-q, --quietPrint only the agent's output.
--sync <live|exit|off>When the folder and the app are brought in step (default live).

App flags, applied when the app is created (--fresh to change an existing one): --cpus (default 2), --memory (default 2gb), --balloon <on|off> (default on), --rootfs-size (default 16gb), --network-mode <nat|off> (default nat), --allow <ENTRY,...|any> (applies at once to an existing app and stays for later sessions; any removes the list), --pull, and --fresh (replace this folder's app; its changes are brought back first).

Folder-app management flags: --status, --sync-now, --sync-deletions (with --sync-now), --stop, --force (with --stop), --rm, --discard (with --rm or --fresh), --ls. One session per app: a second cairn run, and --sync-now, --stop, --rm and --fresh, are refused while a session is attached (cairn exec -it <app> gives another shell; --stop --force interrupts it). --status and --ls only read.

sh
cairn run                       # Claude in this folder
cairn run -- --continue         # resume Claude's last conversation
cairn run --shell               # a shell in the app
cairn run --status              # the app, its sync, repository and session
cairn run --stop                # sync, then stop the app

Type ~. to leave a session. Exit status:

StatusMeaning
the agent's codepassed through unchanged (a sync problem is reported, not folded in)
128 + Nended by signal N
125refused, or the app could not be made ready; the agent did not run. For --sync-now, --stop, --rm and --fresh: the sync, recovery or cleanup was incomplete
130Ctrl+C: a wait ended with nothing changed, or an operation stopped and said what it left
255disconnected (~.) or unknown result

doctor ​

Check host requirements: networking, the jail, deployment tools and the systemd user session.

text
cairn doctor [OPTIONS]
FlagMeaning
-v, --verboseList every check. A terminal shows only checks that need a look; a pipe always gets every check.
sh
cairn doctor
cairn doctor -v
cairn doctor --json

Each finding that needs attention includes its fix. Exit status 0 when no check failed, 1 otherwise, and 130 when interrupted. See troubleshooting.

access ​

Say whether you (or another user) may run VMs on this host, and why. It names every local name that shares the uid, marks each, then gives the verdict.

text
cairn access [OPTIONS] [USER]

USER is a name or uid (default: you).

FlagMeaning
--allList the cairn group's member list, with each name's uid, instead.
--checkExit 1 when the answer is "not allowed", for scripts. Without it the exit status is 0 whatever the answer.
sh
cairn access
cairn access alice --check && echo allowed
cairn access --all

net ​

Manage networks. A network is a private subnet with NAT that one or several apps join. Deploy creates an app's own network for you; use these commands to inspect, repair or share one. Details and the egress allowlist are in networking.

text
cairn net <create|ls|inspect|up|down|destroy|gc> ...
CommandPurpose
net create <NAME>Create and start a network. NAME is 1 to 32 lowercase letters, digits or inner hyphens. --subnet <CIDR> picks the guest subnet (/16 to /29, outside the transit pool; default 10.100.0.0/16).
net lsList networks: subnet, recorded state, whether it runs, members, leaving, attached, ports, stale and unreadable records.
net inspect <NAME>Show each app on a network (address, attached, services, published ports), the egress list and recent refusals, and each difference as a fact. Taps are unknown while it is not running.
net up [NAME]Start, restart or repair a network. Safe to repeat. --all does every defined network and continues past failures.
net destroy <NAME>Remove a network: refused while any app is a member. Running it again finishes an interrupted destroy.
sh
cairn net ls
cairn net inspect shop
cairn net create backend --subnet 10.77.0.0/24
cairn net up --all
cairn net destroy backend

Exit status 0 success, 1 failure (net up --all returns 1 if any network failed), 125 when the privileged helper refuses the request.

volume ​

Manage an app's persistent volumes (declared with [[mounts]]). The concepts, ownership and what happens on redeploy are in volumes; this is the command list.

text
cairn volume <list|extend|backup|verify|restore|repair|destroy> ...
CommandPurpose
volume list [APP]List an app's volumes, or every app's. --backups <DIR> also lists the backups and unfinished backups in that directory. SIZE is the filesystem size; HOST ALLOCATION is what the host's sparse file uses (for guest usage, run cairn exec <app> -- df -h <destination>).
volume extend <APP> <NAME> <SIZE>Grow a volume (4gib, 512mib, 1tib; at most 1 TiB; never shrinks). The app must be stopped; the guest sees the new size at its next boot. An interrupted growth is finished by running it again.
volume backup <APP> <NAME> <DIR>Copy a volume to a new directory (made 0700; holds image.ext4 and manifest.json). The app must be stopped.
volume verify <DIR>Check a backup directory. Writes nothing.
volume restore <APP> <NAME> <DIR>Replace a volume's data with a verified backup. The app must be stopped. An interrupted restore blocks every boot until run again with the same backup.
volume repair <APP> <NAME>Repair a damaged volume, or finish an interrupted repair. Needs --keep <DIR> (a copy first) or --accept-data-loss. --clear-damage only removes the damage note from a consistent volume.
volume destroy <APP> <NAME>Delete a volume and its data; cannot be undone. The app must be stopped. On a terminal it asks you to type the app's name; elsewhere it needs --yes. An interrupted destroy is finished by running it again.

NAME is the volume's name: the source of its [[mounts]] entry.

Every command above except list and verify refuses while a deploy of the app did not finish (cairn stop <app> settles it), and while a machine of the app that mounts the volume is running or waiting to restart. Another command's unfinished work is either taken over (a restore replaces an interrupted growth or repair, a repair finishes an interrupted growth along with its own work, a destroy replaces any of them, and a backup copies an interrupted growth or repair with the data) or refused, naming the command that finishes it.

sh
cairn stop notes
cairn volume extend notes pgdata 4gib
cairn volume backup notes pgdata ~/backups/notes-1
cairn volume verify ~/backups/notes-1
cairn start notes

Exit status 0 success, 1 failure.

kernel ​

Manage the guest kernel the VMs boot. See kernels.

text
cairn kernel <fetch|install> ...
CommandPurpose
kernel fetchDownload the guest kernel, check its sha256, and save it read-only. --name <NAME> picks a known kernel (default: the one this cairn boots).
kernel install <FILE>Install a kernel file you already have (the offline path). --name <NAME> says which known kernel it is. The file is checked against the pinned sha256.
sh
cairn kernel fetch
cairn kernel install ~/Downloads/vmlinux-6.1.155

admin ​

Root's tools: host-wide inventory, cleanup, the maintenance barrier and configuration checks. Several need root. See configuration.

text
cairn admin <inventory|cleanup|maintenance|check-config|check-caps|probe-device> ...
CommandPurpose
admin inventoryList everything cairn has on the host: every network and port record (tombstones included), every live machine tree, every cairn process in /proc. Changes nothing. Root only. --require-quiet exits 0 only when none remain.
admin cleanupFinish stale cleanup: the helper's gc, then the jail's gc. Root only.
admin maintenance beginStop creation, run cleanup, and record whether the host is quiet. Root only. --why <WORD> labels the mark (remove, uninstall, or your own word; default admin). --require-quiet removes the mark and exits 1 when the inventory is not quiet.
admin maintenance endRemove the mark; creation is allowed again. Root only.
admin maintenance statusPrint the mark.
admin check-configParse /etc/cairn/net.conf and vmm.conf with the privileged programs' own parsers. --file <PATH> checks one file instead. Exit 1 if any is invalid.
admin check-caps <PATH>...Compare each file's security.capability with --expect <VALUE> (none, or cap_a,cap_b=ep; default none), as sets. Exit 1 on a mismatch.
admin probe-device <PATH>...Open device paths and report each as JSON. Used by cairn doctor.
sh
sudo cairn admin inventory
sudo cairn admin maintenance begin --why upgrade --require-quiet
sudo cairn admin maintenance end
cairn admin check-config

Exit status, summarised ​

StatusWhereMeaning
0allsuccess
1allthe command failed (access --check: not allowed; ps: something unreadable; admin checks: a check failed)
2all but exec, console, runusage error
125exec, console, run; netrefused before anything ran (for exec/console/run this includes usage errors)
126, 127, 141execcould not run, not found, local pipe closed
128 + Nexec, console, runthe program ended by signal N
130deploy, doctor, start, stop, destroy, pause, resumeinterrupted with Ctrl+C while waiting
255exec, console, rundisconnected, cleanup incomplete or unknown result