Skip to main content
The global options, subcommands, and flags below follow the clap definitions in src/cli/src/ for the latest published version.

Prerequisites

  • The boxlite CLI and a machine with hardware virtualization — see Installation.
  • The boxlite CLI is installed (see “Install and verify” below).

Install and verify


Quick Example (minimal happy path)

The following commands form a complete “pull an image -> run once -> list sandboxes” loop and can be copied and run directly:
boxlite run blocks the foreground by default until the command exits; add -d/--detach to run it in the background and print the box ID immediately. For boxlite exec, separate the command with -- so the command’s own flags are not parsed by the CLI.

Command synopsis

Global options may appear before or after the subcommand and apply to all commands.
Source: src/cli/src/cli.rs:55-108. The Commands enum is marked #[non_exhaustive], so new commands may be added in the future.

Global options

Source: src/cli/src/cli.rs:139-182.

Local vs. remote selection logic

boxlite connects to a remote service when REST configuration is present, otherwise it uses the local runtime (GlobalFlags::create_runtime(), cli.rs:229-245):
  • URL: --url / BOXLITE_REST_URL > the stored profile’s URL. If either is present, it uses the remote BoxliteRuntime::rest.
  • Bearer credential: BOXLITE_API_KEY > the profile’s bearer. BOXLITE_API_KEY overrides only the bearer, not the profile’s url/path_prefix.
  • Route slot: --path-prefix / BOXLITE_REST_PATH_PREFIX > the profile’s path_prefix.
  • If none of these yields a URL -> local runtime.

Subcommands (parameters and returns)

boxlite run

Create a new sandbox and run a command immediately. Blocks the foreground until the command exits; the CLI exit code is the command’s exit code (src/cli/src/commands/run.rs).
run reuses the following shared flag groups: process (-i/-t/-e/-w/-u/--entrypoint), resources (--cpus/--memory/--disk-size), ports (-p), volumes (-v), network (--network/--allow-net), and management (--name/-d/--rm/--security). See “Shared flag groups” below.
With -d/--detach, run returns immediately after printing the box ID and forces auto_remove=false (run.rs:119-121), so you must boxlite rm it manually.

boxlite exec

Run a command in an already running sandbox (src/cli/src/commands/exec.rs).
If the target sandbox is not found, it reports No such box: <BOX> (exec.rs:88).

boxlite create

Create a sandbox only — do not run a foreground command — and print the box ID on success (src/cli/src/commands/create.rs). Operate on it afterwards with boxlite start / boxlite exec.
Supports --name, -e/--env, -w/--workdir, --entrypoint, plus the resources/ports/volumes/network/management shared flag groups.

boxlite list (aliases ls / ps)

List sandboxes (src/cli/src/commands/list.rs). Defaults to table output.

boxlite rm

Remove one or more sandboxes (src/cli/src/commands/rm.rs).

boxlite start / stop / restart

Lifecycle operations on one or more sandboxes (start.rs / stop.rs / restart.rs). All three take only a target list, with no extra flags.

boxlite pull

Pull an image from a registry (src/cli/src/commands/pull.rs).
On success it prints Pulled: <reference> / Digest: / Layers: (pull.rs:24-26).

boxlite images

List local images (src/cli/src/commands/images.rs). Defaults to table.

boxlite inspect

Inspect one or more sandboxes in detail (src/cli/src/commands/inspect.rs). Defaults to JSON.

boxlite cp

Copy files/directories between host and sandbox (src/cli/src/commands/cp.rs). Use BOX:PATH for the sandbox-side path in the source or destination.

boxlite info

Show runtime-level system information (src/cli/src/commands/info.rs). Defaults to YAML.

boxlite logs

View a sandbox’s logs (src/cli/src/commands/logs.rs).

boxlite stats

View a sandbox’s resource usage (src/cli/src/commands/stats.rs). Defaults to table.

boxlite serve

Start the long-running REST API service (a local Axum reference server, src/cli/src/commands/serve/mod.rs). Once running, connect with the SDK’s REST client or with --url.
By default the REST API serves at http://localhost:8100/v1/....

boxlite auth

Authenticate with a remote BoxLite service (src/cli/src/commands/auth/mod.rs). Flags for auth login (auth/login.rs):

boxlite completion

Generate shell completion scripts (src/cli/src/cli.rs:119-133; hidden in --help).

Shared flag groups

The following flag groups are reused across multiple commands (src/cli/src/cli.rs).

Process (ProcessFlags, cli.rs:308)

Resources (ResourceFlags, cli.rs:396)

Port publishing (PublishFlags, cli.rs:476)

Volumes (VolumeFlags, cli.rs:567)

Network (NetworkFlags, cli.rs:438)

Management (ManagementFlags, cli.rs:744)


Volume mount syntax (CLI-only)

The CLI -v uses the strings ro/rw for read/write permission (parsing at cli.rs:591-593), defaulting to rw:
Important distinction: this is the CLI parsing layer’s ro/rw string syntax. In the SDKs (Python/Node), the volume’s third element is a bool read_only (True = read-only / False = read-write), not a string. Do not conflate them (see Python SDK Reference and Node.js SDK Reference).

Port publishing syntax

  • -p 80 -> the host port follows the guest (host_port=None), guest port 80
  • -p 8080:80 -> host 8080 maps to guest 80
  • The /tcp protocol suffix (default) forwards over TCP

Default output formats


Registry configuration

The CLI resolves an unqualified image reference (e.g. alpine) into a fully qualified one (e.g. docker.io/library/alpine:latest) by searching configured registries in order; the first successful pull wins. Fully qualified references (e.g. quay.io/prometheus/prometheus:v2.40.1) always bypass this search and are pulled directly.

Configuration source priority

Configuration sources are layered, from lowest to highest priority (source docs/guides/image-registry-configuration.md):
  1. Default: docker.io (the implicit default when nothing is configured).
  2. Config file (--config <FILE>): registries loaded from the JSON file.
  3. CLI flags (--registry <REGISTRY>): prepended to the config-file registries, so they take the highest priority.

JSON config file schema

A --config file holds an image_registries array. Each entry configures one registry:
Use it with boxlite --config ./registries.json run .... --registry flags, if also present, are prepended (higher priority).

Troubleshooting (common problems and typical errors)

No virtualization / missing KVM, start fails

Symptom: on Linux boxlite run ... reports it cannot access /dev/kvm, or starting a microVM fails on an unsupported platform. Cause: an environment constraint. BoxLite requires hardware virtualization. Fix:
  • Linux: confirm /dev/kvm exists and the current user is in the kvm group (ls -l /dev/kvm, groups).
  • macOS: use Apple Silicon (Hypervisor.framework, no /dev/kvm needed); macOS Intel is not supported.
  • Windows: run inside WSL2 with KVM enabled.

--tty reports “the input device is not a TTY.”

Symptom: boxlite run -t ... or boxlite exec -t ... errors in a non-interactive environment (e.g. CI, a pipe) (run.rs:142-143, cli.rs:359-360). Cause: -t/--tty requires stdin to be a real terminal. Fix: drop -t in scripts/CI; use -it only in an interactive terminal.

exec reports No such box: <BOX>

Symptom: boxlite exec mybox -- ... reports the sandbox is not found (exec.rs:88). Cause: the target sandbox does not exist or was stopped/removed. exec only operates on an existing sandbox. Fix: run boxlite list -a to confirm the box exists; if stopped, boxlite start <BOX> first.

-v used an invalid ro/rw string

Symptom: the CLI reports invalid volume spec .... Cause: the third segment accepts only ro or rw (others are ignored or error), and an anonymous volume’s box path must be absolute (cli.rs:616-621). Fix: use -v host:box:ro or -v host:box (default rw); for an anonymous volume write -v /data, not -v data.
Note: in SDK code (not the CLI), passing the volume’s third element as the string "ro" raises TypeError: 'str' object cannot be cast as 'bool' — the SDK’s third element must be a bool.

--allow-net combined with --network disabled is rejected

Symptom: the error message contains allow_net (cli.rs:1043-1052). Cause: --allow-net implies enabled, which contradicts disabled. Fix: do not add --network disabled when you need allowlisted egress; do not add --allow-net when you need the network fully off.

--security given an unknown preset

Symptom: the error message contains the invalid value you entered (e.g. ultra, cli.rs:1415-1428). Cause: --security accepts only enable / disable (case-insensitive). Fix: use --security=disable to turn the sandbox off (for debugging), or omit the option (default enable).

serve set --api-key but the client gets 401

Symptom: connecting to a service started with boxlite serve --api-key ... returns 401. Cause: once --api-key is set, every route except GET /v1/config requires Authorization: Bearer <KEY> (serve/mod.rs:51-55). Fix: the client must carry the correct bearer (e.g. --url + BOXLITE_API_KEY, or the SDK’s ApiKeyCredential); for local development you can leave --api-key unset (permissive mode).

The one-line install script’s environment variable had no effect

Symptom: BOXLITE_VERSION=... curl ... | sh did not pin the version as expected. Cause: a variable placed before curl applies only to the curl process and is not passed to the installer. Fix: place the variable on the pipe’s sh side: curl -fsSL https://sh.boxlite.ai | BOXLITE_VERSION=v<VERSION> sh (substitute the desired release tag, e.g. the latest published version).

Exit codes

boxlite follows POSIX shell exit-code conventions. The mapping lives at src/cli/src/util/mod.rs:11-15 (to_shell_exit_code). boxlite rm, start, stop, and restart aggregate per-target errors and exit 1 if any target failed, after attempting all targets. You can branch on the exit code directly in a script:

See also