Skip to main content

Overview

SmolVM’s ImageBuilder class provides tools to build custom VM images with SSH pre-configured. Images are built using Docker and cached for reuse.

Quick Start

ImageBuilder Class

Initialization

Check Docker Availability

ImageBuilder requires Docker to be installed and running. On macOS, use Docker Desktop. On Linux, install docker.io.

Build Methods

1. Alpine Linux with SSH Password

Build a minimal Alpine Linux image with password authentication:
Features:
  • Alpine Linux 3.19 base
  • OpenSSH server pre-configured
  • Root password authentication enabled
  • Custom /init script for network setup
  • DNS resolution configured (8.8.8.8, 8.8.4.4)
Method Signature:
Build Alpine with public key authentication (more secure):
Method Signature:

3. Debian Linux with SSH Key

Build a Debian-based image (larger but more compatible):
Method Signature:

Boot Arguments

Use the SSH_BOOT_ARGS constant for SSH-capable images:
The init=/init parameter is required for SmolVM’s SSH functionality. Without it, the custom init script won’t run and SSH won’t start.

Caching Behavior

ImageBuilder caches built images to avoid rebuilding:

Cache Invalidation

For key-based images, the cache is invalidated if the SSH key is newer than the cached image:

Custom Cache Directory

Advanced: Kernel URLs

Override the default kernel URL:
Default Kernel URLs:

Real-world Example: OpenClaw Installation

From examples/openclaw.py - building a 4GB Debian image for OpenClaw:

The Init Script

All SSH-capable images include a custom /init script that runs as PID 1:
This init script:
  • Mounts essential filesystems
  • Configures networking from kernel boot args
  • Sets up DNS resolution
  • Generates SSH host keys
  • Starts the SSH daemon
  • Stays alive as PID 1

Troubleshooting

Docker Not Found

Solution:
  • macOS: Install Docker Desktop
  • Linux: sudo apt-get install docker.io (Debian/Ubuntu)

Permission Errors (Linux)

If you see permission errors during image builds on Linux:

Image Build Fails

If Docker build fails:
1

Check Docker is running

2

Clean Docker cache

3

Check disk space

Image builds require sufficient disk space:

Next Steps

Environment Variables

Inject configuration into custom images

AI Agent Integration

Build specialized images for AI agent sandboxes

VM Lifecycle

Manage VMs built with custom images