SmolBox

Run Python, JavaScript and other programs in disposable or retained Linux VMs from Elixir.

SmolBox is a client and supervised execution runtime for smolvm. SmolBox runs VMs through a local Embedded Port helper or connects to an external smolvm HTTP worker. It tracks command identity, results and cleanup under your application's supervision tree.

An opt-in Kubernetes development preview supports disposable execution on one enrolled Linux/K3s node using SmolVM. Its fixed image/resource policy, positive cleanup proof and manual lab setup are separate from the HTTP and Embedded production configurations.

Start here

For a first local run, follow the Embedded Port quickstart. It installs a verified native bundle and runs one offline command on Apple Silicon, Linux x86_64 or Linux ARM64. You need Elixir 1.18 or later and the host prerequisites. SmolBox starts the helper from your Mix application without a separate HTTP server.

This checkout defaults to SmolVM 1.35.1 using completed local qualification. Reviewed source/notices are published. The v0.6.1-rc.1 native bundles passed all six public installer lanes. The final v0.6.1 bundles are built and attested separately, with their own public installer qualification. Hex remains unpublished during final qualification; use the matching Git tag or a locally built Elixir package. Existing bundles keep their original identities. See upgrade guidance and qualification and distribution status. For a separate SmolVM server, follow the HTTP worker quickstart.

Held branches can receive their own non-secret environment values at release. On Linux x86_64, both backends support opt-in allowlisted branch egress and per-child HTTPS Bearer credentials. See Managed branches and Upgrading to 0.6.0.

Why use SmolBox?

Executing a command is only part of integrating a worker. Your application also needs to handle duplicate requests, lost responses, restarts and leftover VMs.

What execution looks like

This fragment illustrates submitting a command to an already configured runtime. It assumes SmolBoxDemo.Runtime is running and artifact and profile are available in the same code context. For a complete runnable example, use Getting started with an HTTP worker. The walkthrough stops its demo supervisor after cleanup.

alias SmolBox.{Command, ExecutionSpec}

argv = ["python", "-c", "print(6 * 7)"]
{:ok, command} = Command.new(argv, timeout_secs: 10)

{:ok, spec} =
  ExecutionSpec.new(
    scope: "demo",
    id: "answer-001",
    artifact: Map.drop(artifact, ["path"]),
    profile: profile,
    command: command
  )

{:ok, handle} = SmolBox.submit(SmolBoxDemo.Runtime, spec)
{:ok, ^handle} = SmolBox.submit(SmolBoxDemo.Runtime, spec)

{:ok, execution} =
  SmolBox.await(SmolBoxDemo.Runtime, handle, 90_000)

%{state: :completed, result: result} = execution
%{exit_code: 0, stdout: stdout} = result

IO.write(stdout)
# Prints: 42

The second submission reuses the execution. The specification uses the image identity from artifact and the registered profile created during setup. Handle errors, nonzero exits and unknown outcomes in application code. An await/3 timeout does not cancel the command. Inspect cleanup with SmolBox.fetch/3; see Troubleshooting.

Choose your next step

What you want to do Guide
Add supervision, profiles and durable storage Host integration
Keep a machine and its files across commands Persistent machines
Manage the lifecycle yourself Low-level client
Use registry images or prepared artifacts Images and registry artifacts
Run longer commands, background processes or a terminal Long commands · Terminals
Transfer files or retain data after machine deletion Guest files · Local volumes
Reuse prepared disk or memory state Exports · Checkpoints · Branches
Configure networking or expose a guest service Network access · Port mappings
Recover from failures or prepare maintenance Recovery · Draining

The community workspace app provides a Phoenix walkthrough using its pinned SmolBox 0.3.0 dependency. It includes persistent machines, commands, a terminal and PostgreSQL recovery. The engineering blog has longer worked examples.

Deployment and support

SmolBox is ready for production use on documented configurations. Check the validated configurations for the backend, host, features and storage you plan to deploy.

SmolBox relies on smolvm for VM isolation. Your deployment controls worker access, image approval, host resource limits, networking, credentials and storage. Admission reservations do not enforce host quotas. Offline networking is the default, and retained machines remain until explicitly deleted. Read Deployment boundaries before operating workers.

Contributing

Source: hfiguera/smolbox. Toolchain pins are in .tool-versions. Run mix ci for deterministic checks without a real worker. Build the documentation with MIX_ENV=dev mix docs --warnings-as-errors, then run MIX_ENV=dev mix smolbox.ci.docs to check local links and fragments. Live worker checks are a separate operation described in the repository's CI guide.