src/cli/src/ for the latest published version.
Prerequisites
- The
boxliteCLI and a machine with hardware virtualization — see Installation. - The
boxliteCLI 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 runblocks the foreground by default until the command exits; add-d/--detachto run it in the background and print the box ID immediately. Forboxlite exec, separate the command with--so the command’s own flags are not parsed by the CLI.
Command synopsis
Source:src/cli/src/cli.rs:55-108. TheCommandsenum 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 remoteBoxliteRuntime::rest. - Bearer credential:
BOXLITE_API_KEY> the profile’s bearer.BOXLITE_API_KEYoverrides 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.
Related environment variables
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,runreturns immediately after printing the box ID and forcesauto_remove=false(run.rs:119-121), so you mustboxlite rmit 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).
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.
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’sro/rwstring syntax. In the SDKs (Python/Node), the volume’s third element is abool 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
/tcpprotocol 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 (sourcedocs/guides/image-registry-configuration.md):
- Default:
docker.io(the implicit default when nothing is configured). - Config file (
--config <FILE>): registries loaded from the JSON file. - 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 Linuxboxlite 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/kvmexists and the current user is in thekvmgroup (ls -l /dev/kvm,groups). - macOS: use Apple Silicon (Hypervisor.framework, no
/dev/kvmneeded); 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"raisesTypeError: 'str' object cannot be cast as 'bool'— the SDK’s third element must be abool.
--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:

