Skip to content

Self-Hosting

The Quickstart gets you to your first sandbox. This is the longer operator path — the service, control API, remote access, data and updates. One box running your own agents is enough; you don’t need a cluster.

  • Linux x86_64 or arm64 with KVM: /dev/kvm must be available (cloud VMs need nested virtualization). The installed daemon runs under systemd.
  • macOS on Apple Silicon with HVF: the signed bhatti-vmm carries the hypervisor entitlement. Intel Macs aren’t supported. The installed daemon runs under launchd.
  • Root for the installer on both platforms. HVF itself doesn’t require root, but installing the service, group and data directory does. Allow RAM for the guests you expect to run; NVMe helps with disks and snapshots.

I run it on Raspberry Pi 5s, a Hetzner box and a Mac. v2’s qcow2 overlays share read-only base images, so ext4, xfs, btrfs and APFS all work; no special host filesystem is required.

Terminal window
curl -fsSL bhatti.sh/install | sudo bash

The installer chooses a default Ubuntu 24.04 rootfs tier, downloads the CLI and runtime bundle (bhatti-vmm, bhatti-netd, libkrun, the guest kernel and lohar), installs a systemd or launchd service and creates an admin API key. It writes the key into the invoking user’s ~/.bhatti/config.yaml and prints it once. Save it securely. --tier browser selects a default; --tiers all also installs the other tiers:

Terminal window
curl -fsSL bhatti.sh/install | sudo bash -s -- --tier browser --tiers all

For tier choices, see Tiers. The local CLI is ready immediately:

Terminal window
bhatti create --name test
bhatti exec test -- uname -a
bhatti destroy test

A new sandbox has no guest network device. Give a network-dependent workload deliberate outbound access with create --net or scoped egress rules; see Networking. This is separate from the host control API and publishing a guest service.

A fresh installer writes api_socket: <data_dir>/api.sock and api_socket_gid for its bhatti group. The daemon creates a root-owned socket with mode 0660 for that group. The installer adds the invoking user to the group; refresh your login/group membership if the current shell can’t open the socket. The data directory must also be traversable by that group — the installer warns if an existing directory’s permissions block access; review them carefully because secret data lives there. The daemon’s default without an assigned GID is owner-only mode 0600. Unix socket access is not authentication: every control API request still needs Authorization: Bearer <key>. The installer saves the admin key for the local CLI; bhatti version shows the endpoint it uses.

On Linux the usual data dir is /var/lib/bhatti; use the configured data_dir on other installations. You can call the API without enabling TCP:

Terminal window
curl --unix-socket /var/lib/bhatti/api.sock \
-H 'Authorization: Bearer bht_...' http://unix/sandboxes

The CLI resolves its endpoint in this order: --url, BHATTI_URL, api_url from config, then the local socket. It resolves the key from --token, BHATTI_TOKEN, then auth_token in config. Set an explicit remote URL if your environment or config already points elsewhere. See Configuration for the precise paths and options.

The installed unit is /etc/systemd/system/bhatti.service on Linux. The Mac uses /Library/LaunchDaemons/sh.bhatti.plist. To inspect or restart:

Terminal window
# Linux
sudo systemctl status bhatti
sudo journalctl -u bhatti -f
sudo systemctl restart bhatti
# macOS
sudo launchctl print system/sh.bhatti
sudo launchctl kickstart -k system/sh.bhatti
# Logs: <data_dir>/bhatti.log

The daemon logs structured JSON. The macOS plist sends stdout and stderr to <data_dir>/bhatti.log; on Linux, journalctl reads the service logs. BHATTI_LOG_LEVEL=debug enables verbose logging. After changing server configuration, restart the appropriate service.

The fresh install has no TCP API listener: no implicit :8080, no HTTPS endpoint and no automatically public URL. The local Unix socket is the preferred control channel. From a laptop, SSH to the server and use the CLI on that host, where its user needs socket group access and an API key:

Terminal window
ssh you@your-server 'bhatti version'
ssh you@your-server 'bhatti list'

To run the CLI on the laptop instead, configure a domain for the authenticated HTTPS API. Install the CLI-only binary there, then use the key issued for this agent or person:

Terminal window
curl -fsSL bhatti.sh/install | bash
bhatti setup --url https://api.yourdomain.com --token bht_...

Give each agent or person a separate key where useful; see Users & Auth.

The daemon always serves the Unix socket. Outside domain mode, you can add listen: 127.0.0.1:8080 (or another explicit address) to the server config to opt into a second, plaintext HTTP TCP listener; it still requires a bearer token. Keep such a listener trusted and private. Do not bind it to an untrusted network or send API keys across plaintext links. Domain mode instead serves TLS on :443 (API host and public published aliases) and redirect/ACME on :80, while retaining the Unix socket — not a hidden localhost :8080 listener. It ignores listen and public_proxy_listen. Without domain mode, an explicit public_proxy_listen can serve unauthenticated path-based HTTP URLs for development/testing, separate from the authenticated control API. With neither public proxy configured, publish offers an authenticated local API proxy path, not a public URL. For the manual DNS/certificate setup see Custom domain.

Back up <data_dir>/state.db and its WAL coherently (sqlite3 .backup or a stopped-service copy), <data_dir>/age.key (needed to decrypt secrets), <data_dir>/volumes/, and any sandbox or snapshot state you need to keep. Sandboxes may contain irreplaceable writes: don’t assume all are reproducible. <data_dir>/images/bases/ holds immutable base images still used by sandboxes and snapshots; preserve referenced bases when moving a data directory. <data_dir>/runtime/ is reinstalled on update, not user data. See Durability, Storage and Volume backups.

Terminal window
sudo bhatti update
sudo bhatti update --tiers all

See Updating & Uninstalling for upgrade caveats, macOS service handling and the uninstall commands. Configuration lists the on-disk layout.