Skip to main content
This page covers the everyday operations you need to work with SmolVM: creating a sandbox, running commands inside it, reading the output, and handling errors. If you have not installed SmolVM yet, start with the quickstart.

Quick start

The simplest way to use SmolVM is the auto-configuration mode:
When you create a SmolVM() with no arguments, it automatically:
  • Generates SSH keys (stored in ~/.smolvm/keys/)
  • Builds an Alpine Linux image with SSH pre-configured
  • Creates a VM with sensible defaults (512MB RAM, 1 vCPU)
  • Starts the VM when entering the context manager

Creating a sandbox

You can create a sandbox with sensible defaults or customize the configuration.

Running commands

The run() method executes commands via SSH and returns a CommandResult object:

Shell modes

SmolVM supports two command execution modes:

VM properties

Access VM information through properties:

Checking SSH capability

Not all VM images support command execution. You can check before running commands:
Command execution requires the VM to be booted with init=/init in the boot arguments. All auto-configured VMs and images built with ImageBuilder include this by default.

Getting SSH connection details

Retrieve SSH commands for manual connection:

Error handling

SmolVM raises specific exceptions for different failure scenarios:

Next steps

VM lifecycle

Learn about starting, stopping, and managing VM lifecycles

Port forwarding

Expose guest services to your host machine

Environment variables

Inject configuration into your VMs

Custom images

Build custom rootfs images for your use case
Last modified on May 5, 2026