展示HN:小机器 – 亚秒级冷启动,可移植虚拟机
Show HN: Smol machines – subsecond coldstart, portable virtual machines

原始链接: https://github.com/smol-machines/smolvm

## Smolmachine:用于现代工作负载的隔离微型虚拟机 Smolmachine 是一款 CLI 工具,用于在轻量级、隔离的虚拟机中运行和部署应用程序。它使用硬件隔离(macOS 上的 Hypervisor.framework 或 Linux 上的 KVM)提供亚秒级启动时间和跨平台兼容性(macOS 和 Linux)。 主要特性包括: * **隔离性:** 每个工作负载拥有自己的内核,提供强大的安全性并防止干扰。 * **可移植性:** 将虚拟机打包成单个 `.smolmachine` 文件,方便分发和执行。 * **效率:** 弹性内存使用和空闲 vCPU 线程可最大限度地减少资源消耗。 * **灵活性:** 运行临时命令,创建持久的开发环境,或将应用程序打包成自包含的二进制文件。 * **安全性:** 默认禁用网络访问,并可锁定到特定主机。SSH 代理转发允许安全地访问 Git,而无需暴露私钥。 * **配置:** 使用 `Smolfile` 定义可重现的虚拟机配置。 Smolmachine 为容器提供了一种引人注目的替代方案,它提供更强的隔离性,同时具有可比的速度和效率。它非常适合运行不受信任的代码、编码代理以及开发隔离环境。

## Smol Machines:一种新的虚拟化方法 一个名为“Smol Machines” (github.com/smol-machines) 的新项目旨在用轻量级虚拟机取代 Docker 容器,提供类似容器的人体工学和**亚秒级的冷启动时间**。该创建者曾就职于 AWS 和 Firecracker,认为容器增加了不必要的开销,而 Firecracker 对于典型的用户工作负载来说过于繁重。 Smol Machines 是一种混合方法,结合了两种技术的优点。它通过积极地将 Linux 内核精简到运行所需的最低限度来实现快速启动。虚拟机在重启后保留文件数据,并且可以打包为单个可移植文件。 该项目正在寻求反馈,并与类似的项目如 `shuru.run` 和 `OrbStack` 进行了比较。开发者澄清他们使用多个 HN 帐户是由于 GitHub 的隶属关系不同。重点是为本地开发和托管环境提供轻量级解决方案。
相关文章

原文

smol machines

Discord Release License

Ship and run software with isolation by default.

This is a CLI tool that lets you:

  1. Manage and run custom Linux virtual machines locally with: sub-second cold start, cross-platform (macOS, Linux), elastic memory usage.
  2. Pack a stateful virtual machine into a single file (.smolmachine) to rehydrate on any supported platform.
# install (macOS + Linux)
curl -sSL https://smolmachines.com/install.sh | bash

# for coding agents — install + discover all commands
curl -sSL https://smolmachines.com/install.sh | bash && smolvm --help

Or download from GitHub Releases.

# run a command in an ephemeral VM (cleaned up after exit)
smolvm machine run --net --image alpine -- sh -c "echo 'Hello world from a microVM' && uname -a"

# interactive shell
smolvm machine run --net -it --image alpine -- /bin/sh
# inside the VM: apk add sl && sl && exit

Sandbox untrusted code — run untrusted programs in a hardware-isolated VM. Host filesystem, network, and credentials are separated by a hypervisor boundary.

# network is off by default — untrusted code can't phone home
smolvm machine run --image alpine -- ping -c 1 1.1.1.1
# fails — no network access

# lock down egress — only allow specific hosts
smolvm machine run --net --image alpine --allow-host registry.npmjs.org -- wget -q -O /dev/null https://registry.npmjs.org
# works — allowed host

smolvm machine run --net --image alpine --allow-host registry.npmjs.org -- wget -q -O /dev/null https://google.com
# fails — not in allow list

Pack into portable executables — turn any workload into a self-contained binary. All dependencies are pre-baked — no install step, no runtime downloads, boots in <200ms.

smolvm pack create --image python:3.12-alpine -o ./python312
./python312 run -- python3 --version
# Python 3.12.x — isolated, no pyenv/venv/conda needed

Persistent machines for development — create, stop, start. Installed packages survive restarts.

smolvm machine create --net myvm
smolvm machine start --name myvm
smolvm machine exec --name myvm -- apk add sl
smolvm machine exec --name myvm -it -- /bin/sh
# inside: sl, ls, uname -a — type 'exit' to leave
smolvm machine stop --name myvm

Use git and SSH without exposing keys — forward your host SSH agent into the VM. Private keys never enter the guest — the hypervisor enforces this. Requires an SSH agent running on your host (ssh-add -l to check).

smolvm machine run --ssh-agent --net --image alpine -- sh -c "apk add -q openssh-client && ssh-add -l"
# lists your host keys, but they can't be extracted from inside the VM

smolvm machine exec --name myvm -- git clone [email protected]:org/private-repo.git

Declare environments with a Smolfile — reproducible VM config in a simple TOML file.

image = "python:3.12-alpine"
net = true

[network]
allow_hosts = ["api.stripe.com", "db.example.com"]

[dev]
init = ["pip install -r requirements.txt"]
volumes = ["./src:/app"]

[auth]
ssh_agent = true
smolvm machine create myvm -s Smolfile
smolvm machine start --name myvm

More examples: python · node · doom

Each workload gets real hardware isolation — its own kernel on Hypervisor.framework (macOS) or KVM (Linux). libkrun VMM with custom kernel: libkrunfw. Pack it into a .smolmachine and it runs anywhere the host architecture matches, with zero dependencies.

Defaults: 4 vCPUs, 8 GiB RAM. Memory is elastic via virtio balloon — the host only commits what the guest actually uses and reclaims the rest automatically. vCPU threads sleep in the hypervisor when idle, so over-provisioning has near-zero cost. Override with --cpus and --mem.

smolvm Containers Colima QEMU Firecracker Kata
Isolation VM per workload Namespace (shared kernel) Namespace (1 VM) Separate VM Separate VM VM per container
Boot time <200ms ~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
Host Guest Requirements
macOS Apple Silicon arm64 Linux macOS 11+
macOS Intel x86_64 Linux macOS 11+ (untested)
Linux x86_64 x86_64 Linux KVM (/dev/kvm)
Linux aarch64 aarch64 Linux KVM (/dev/kvm)
  • Network is opt-in (--net on machine create). TCP/UDP only, no ICMP.
  • Volume mounts: directories only (no single files).
  • macOS: binary must be signed with Hypervisor.framework entitlements.
  • --ssh-agent requires an SSH agent running on the host (SSH_AUTH_SOCK must be set).

See docs/DEVELOPMENT.md.

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

联系我们 contact @ memedata.com