跳到主要内容

CLI 概览

二进制​

rc 是 host 端的二进制。它运行在 macOS Apple Silicon 以及带 KVM 的 Linux x86_64/aarch64 上。

rc --help
子命令作用页面
run在一台全新的 VM 中执行代码(冷启动),输出以 streaming 方式显示run 与 shell
shell在某个 stack 的全新 VM 中打开交互式 shellrun 与 shell
machine ...持久化机器:create、start、exec、shell、cp、logs、stop、delete、run、branch、pause、resume、sync、update、status、ls、data-dir、prunemachine、runner.code、网络与卷
pack ...create、inspect、prune:把镜像或机器打包成可移植制品pack
serve带预启动 VM pool 和机器路由的 HTTP APIHTTP API
image build、image prune从官方 OCI 镜像为一个或多个 stack 生成 ext4;清理缓存image
languages列出目录,以及每个 stack 的镜像是否已构建见下文
doctor检查 host 能否运行 microVM,以及它提供哪些能力见下文
vmm单台 VM 的进程;内部使用,由 launcher 调用libkrun

guest(runner-guest)是另一个二进制,只在 VM 内运行;不需要手动调用。

languages​

rc languages

目录中每个 stack 一行;ext4 已在缓存中时显示 ready=true,并给出源 OCI 镜像:

awk      ready=true  alpine:3.22
...
llama ready=true fedora:43
nodejs ready=false node:22-alpine
python ready=true python:3.12-alpine

doctor​

rc doctor

每项一行,状态为 ok、info、warn 或 FAIL。在 Mac M1 Pro 上的真实输出:

ok    platform
ok libkrun
ok gpu: libkrun built with virtio-gpu (Venus); use --gpu on a stack with gpu
info cuda: not supported (no CUDA remoting; --gpu is Vulkan)
info nested: not supported on this host; --nested is refused
ok guest
info sandbox: macOS has no Landlock/seccomp; the VM process runs unconfined
ok image awk
...
项检查内容
platformApple Silicon 上的 macOS,或可读写打开 /dev/kvm 的 Linux
libkrun能否从配置的路径加载该库
gpu、cudalibkrun 是否带 virtio-gpu(Venus);不支持 CUDA
nestedhost 是否支持嵌套虚拟化(--nested)
guestguest 二进制是否位于 host 二进制旁边
sandboxLinux 上 Landlock 的 ABI 和 seccomp;ABI < 9 时给出警告
image <stack>每个已构建的镜像一行

失败输出为 FAIL <item> <motivo>,只要有一项失败,命令就以错误退出。

环境变量​

变量默认值用途
RUNNER_LISTEN127.0.0.1:8080serve 的地址
RUNNER_CACHE_DIR~/Library/Caches/runner-codes(macOS),~/.cache/runner-codes(Linux)镜像、构建 VM、机器、pack、socket
RUNNER_KRUN_LIB~/.nix-profile/lib/libkrun.dylib(macOS);Linux 上为 ~/.nix-profile/lib/libkrun.so.1 或 soname libkrun.so.1libkrun 的路径
RUNNER_GUEST_BIN与 host 同目录的 rc-guest-linux-<arch>注入镜像的 guest
RUNNER_SANDBOX开启off 会关闭 Linux 上的 Landlock + seccomp,仅用于诊断

通过 Taskfile​

Task等价于
task run -- <flags>./bin/rc run <flags>
task shell -- <flags>./bin/rc shell <flags>
task serve -- <flags>./bin/rc serve <flags>
task image:build -- <flags>./bin/rc image build <flags>
task doctor./bin/rc doctor