smolvm README

项目的 README,来自 github.com/smol-machines/smolvm。合并为一个 markdown 文件:README.md。

smol machines

Discord Release License npm PyPI crates.io

English · 中文 · 日本語 · 한국어 · Русский · Español · Deutsch

smolvm

Branchable microVMs for AI agents. Embed lightweight virtual machines into your software, portable dev environments, and local sandboxing.

Install

brew install smol-machines/tap/smolvm                  # macOS (Homebrew)
curl -sSL https://smolmachines.com/install.sh | bash   # macOS + Linux

Windows: unzip the windows-x86_64 release and run smolvm.exe (needs the Windows Hypervisor Platform). Coding agents: run smolvm --help after installing to discover every command.

The documentation for humans and agents is in docs/, one folder per task: a README.md with the facts and a SKILL.md an agent can follow, with its scripts, beside the reference page for each feature.

Quick Start

smolvm machine run --net --image alpine -- uname -a          # one-off VM, removed on exit
smolvm machine run --net -it --image alpine -- /bin/sh       # interactive shell

Local

Real VMs with their own kernel, free on your laptop or your own servers. They boot in under a second, and memory is elastic, so the host only commits what the guest uses. Machines persist across restarts, and any OCI image works, including ones you build locally.

smolvm machine create --net --name dev && smolvm machine start --name dev
smolvm machine exec --name dev -- apk add git
docker save myapp | smolvm machine run --image - -- ./app    # local image, no registry

Mount an S3, R2 or MinIO bucket with -v s3://bucket/prefix:/data, see volumes.

Declare a machine in a Smolfile: image, resources, ports, mounts and network policy in one checked-in file.

Start it with --auto-ports and every TCP port a process inside listens on appears on 127.0.0.1 at the same number while it listens, so dev servers, docker compose and Testcontainers inside the machine need no -p, see publishing ports.

Embeddable

Drive machines from your own code with one Machine API. The SDKs run in your process with no daemon, locally or on smol cloud.

npm install smolmachines     # Node / TypeScript
pip install smolmachines     # Python
cargo add smolmachines       # Rust
go get github.com/smol-machines/smol/sdk/go   # Go
import { Machine } from 'smolmachines';

const m = await Machine.create({ image: 'python:3.12-alpine', network: true });
const r = await m.exec(['python3', '-c', 'print(2 ** 10)']);
console.log(r.stdout); // 1024
await m.delete();

Source and docs: smol-machines/smol · smolmachines.com/docs/sdk

Branchable

Save a running machine mid-execution, rewind it, or branch it into copies that keep running from the same point. Checkpoints capture RAM, CPU state and disks; branches are copy-on-write children of a live machine.

smolvm machine create --net --name agent --image alpine
smolvm machine start --name agent --branchable
smolvm machine branch --from agent --name try-1                   # live copy-on-write child
smolvm machine checkpoint --name agent -o agent.checkpoint        # save it, processes and all
smolvm machine create --name agent2 --from agent.checkpoint       # resume later or elsewhere

Rewind to an earlier generation with --from <checkpoint> --at '~N' (see machine checkpoint-log), and stop without losing execution with pause and resume. A checkpoint taken on an arm64 Mac resumes on arm64 Linux, see Moving a running machine from a Mac to Linux. More in Branching and incremental checkpoints.

Portable

Pack a machine, however you set it up, into a single .smolmachine file. Push it to any OCI registry, or run it as a self-contained executable that boots in under 200 ms with nothing to install.

smolvm machine stop --name dev && smolvm pack create --from-vm dev -o dev
smolvm pack push --file dev.smolmachine ghcr.io/you/dev:v1
smolvm pack create --image python:3.12-alpine -o ./python312
./python312 run -- python3 --version

Checkpoints are portable too: restore one on another host or on smol cloud.

Safe

Each workload gets a hardware-isolated VM with its own kernel. Networking is off by default, egress can be limited to named hosts, and code can use a credential without ever reading it.

Safety is a shared responsibility. smolvm provides the boundary: a separate VM and kernel for every workload, with nothing reaching the host unless you allow it. You decide what crosses that boundary. Every folder you mount, port you open, host you allow, and secret or SSH agent you forward becomes something the workload can use, so give an untrusted workload only what it needs.

smolvm machine run --net --image alpine --allow-host registry.npmjs.org -- wget -qO- https://google.com   # blocked
smolvm machine run --net --image alpine --allow-host-pattern registry.npmjs.org -- wget -qO- https://registry.npmjs.org   # exact host only
NOTION_API_KEY=secret_… smolvm machine run --net --image alpine \
  --credential [email protected] -- sh -c 'echo $NOTION_API_KEY'   # a placeholder

See credential substitution and the security model. Use --allow-host-pattern '*.example.com' to allow subdomains only; --allow-host example.com allows the apex and its subdomains. smolvm machine update adds (--allow-host, --allow-host-pattern, --allow-cidr) and removes (--remove-allow-host, a host or pattern as it was added; --remove-allow-cidr) entries, also on a running machine started with an allow list: a grant applies to the next connection or lookup, and a removed host's learned addresses go with it. On a stopped machine, --allow-private, --remove-allow-private and --reset-allow-private change the private ranges reopened under --block-private (for example a database endpoint whose private address moved) without recreating it.

How It Works

Each workload runs in a hardware-virtualized VM with its own guest kernel on Hypervisor.framework (macOS), KVM (Linux), or the Windows Hypervisor Platform (Windows). libkrun is the VMM and libkrunfw supplies the guest kernel. Images use the OCI format, so anything on Docker Hub, ghcr.io or another registry boots as a microVM, with no Docker daemon.

Defaults: 4 vCPUs, and half the host's RAM up to 8 GiB. Memory is elastic via virtio balloon and idle vCPUs sleep in the hypervisor, so over-provisioning costs almost nothing. Override with --cpus and --mem.

Comparison

smolvm Containers Colima QEMU Firecracker Kata
Workload boundary VM + guest kernel Namespace + shared kernel Namespace inside shared VM VM + guest kernel VM + guest kernel VM per container
Boot time <200ms to agent ready ~100ms ~seconds ~15-30s <125ms ~500ms
Architecture Library (libkrun) Daemon Daemon (in VM) Process Process Runtime stack
Per-workload VMs Yes No No (shared) Yes Yes Yes
macOS native Yes Via Docker VM Yes (krunkit) Yes No No
Embeddable SDK Yes No No No No No
Portable artifacts .smolmachine Images (need daemon) No No No No

Platform Support

Host Guest Requirements
macOS Apple Silicon arm64 Linux macOS 11+
macOS Intel x86_64 Linux no release build published; untested
Linux x86_64 x86_64 Linux KVM (/dev/kvm)
Linux aarch64 aarch64 Linux KVM (/dev/kvm)
Windows x86_64 x86_64 Linux Windows Hypervisor Platform (WHP) enabled

Windows supports portable checkpoints, pause/resume, and branches with --freeze-source. GPU acceleration remains unavailable; see known limitations.

More

smolvm is the open-source runtime behind smol machines, and is not affiliated with other projects named SmolVM.

Apache-2.0 · made by @binsquare · twitter · github

smolvm (smol-machines/smolvm)

正在搜索数据库…

这是什么?smolvm 是一个命令行工具,用于运行可嵌入、可移植、可分支的虚拟机,让你能在本地安全地运行 AI 智能体和不可信代码,并且在 macOS、Linux 和 Windows 上冷启动只需不到一秒。
这跟 Docker 差不多,只不过用虚拟机代替容器,对吧?是的。Smolfile 使用 TOML 编写,作用与 Dockerfile 相同,但它定义的是一整台虚拟机(镜像、资源、网络策略、挂载、端口、初始化命令),启动后由真正的虚拟化监控程序提供隔离,而不是靠容器的命名空间。
怎样安装并让虚拟机跑起来?从 GitHub Releases 下载适用于你平台的版本,把二进制文件放到 ~/.local/share/ 目录下;在 Windows 上则下载 windows-x86_64 版本(其中包含 krun.dll 和 libkrunfw.dll),解压后运行 smolvm.exe。
在 Windows 上或者要用 GPU 加速,需要额外准备什么吗?在 Windows 上必须启用 Windows Hypervisor Platform(WHP)功能。GPU 加速需要编译时启用 GPU=1 的 libkrun,并且宿主机上要装有 virglrenderer 和 Vulkan 驱动;CUDA 远程调用还需要 NVIDIA 显卡并正确安装 NVIDIA 驱动。
Windows 上目前还有哪些功能不能用?GPU 加速,以及 machine branch 和 machine checkpoint 功能,目前在 Windows 上还不可用。另外,pack create 需要把 storage-template.ext4 和 overlay-template.ext4 放在 smolvm.exe 旁边,因为 Windows 上没有宿主机的 mkfs.ext4。
沙箱里的 AI 智能体和我的真实电脑隔离得有多彻底?不可信代码运行在硬件隔离的虚拟机中,宿主机的文件系统、网络和凭据通过虚拟化监控程序的边界与客户机分开,这比一般容器沙箱的隔离保障更强。
“branching”一台机器是什么意思?分支(branch)是对正在运行的机器做的一份写时复制(copy-on-write)的实时副本,它会继承源机器的进程、内存和磁盘状态继续运行。你可以从同一个检查点分出许多子虚拟机,适合并行运行多个智能体任务等场景。
我能把 smolvm 和 Kubernetes 一起用吗?可以。smolvm 自带 containerd shim v2,因此 Kubernetes 可以通过 RuntimeClass 把一个 Pod 作为独立的微虚拟机来运行,这和 Kata Containers 使用的集成方式相同。
smolvm 里的 CUDA API 远程调用是什么?--cuda 参数让没有安装驱动的客户机通过 vsock 把 CUDA 调用转发给宿主机上的一个进程,由该进程借助宿主机的 NVIDIA 驱动执行。它不是 GPU 直通,也不是为多租户场景设计的强化隔离边界。
我能把配置好的机器分享给别人吗?可以。已停止的机器可以打包成一个 .smolmachine 文件,推送到任意 OCI 镜像仓库;其他人拉取后,就能在别处启动一台完全相同的机器。
有哪些类似的项目?coop, nvx, arcbox, CubeSandbox, sandstorm, SPACE, quicksand, agentbox
大小
72.4 MB
星标
7.2K
时长
11个月
提交 · 90 天