Overview
SmolVM’sImageBuilder 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:- Alpine Linux 3.19 base
- OpenSSH server pre-configured
- Root password authentication enabled
- Custom
/initscript for network setup - DNS resolution configured (8.8.8.8, 8.8.4.4)
2. Alpine Linux with SSH Key (Recommended)
Build Alpine with public key authentication (more secure):3. Debian Linux with SSH Key
Build a Debian-based image (larger but more compatible):Boot Arguments
Use theSSH_BOOT_ARGS constant for SSH-capable images:
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:Real-world Example: OpenClaw Installation
Fromexamples/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:
- 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
- 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