Skip to content

feat(microsandbox driver): env knobs for DNS rebind protection and VM size#91

Draft
zhuanyongxigua wants to merge 2 commits into
mainfrom
feat/microsandbox-net-and-vm-size
Draft

feat(microsandbox driver): env knobs for DNS rebind protection and VM size#91
zhuanyongxigua wants to merge 2 commits into
mainfrom
feat/microsandbox-net-and-vm-size

Conversation

@zhuanyongxigua

Copy link
Copy Markdown
Collaborator

背景

在自部署 agent-compose(microsandbox driver)上跑 docker-in-VM / 内网拉镜像时,发现 driver 缺两类可配项,导致 VM 内网络和资源不可用。本 PR 加三个 env 开关,全部默认关/默认值,不设则行为完全不变

改动

pkg/config/config.go + pkg/driver/microsandbox_runtime.go

  • MICROSANDBOX_DISABLE_DNS_REBIND_PROTECTION(bool,默认 false):为 true 时关闭 microVM 的 DNS rebind 防护,使 guest 能把内网域名解析到私网 IP(如内网容器 registry)。内网部署里 VM 要 docker pull / apt 私有主机时必需。→ WithNetwork(... DNS.RebindProtection=false)
  • MICROSANDBOX_MEMORY_MIB / MICROSANDBOX_CPUS(默认 0 = 用 SDK 默认 512MiB/1CPU):调大 microVM 规格。SDK 默认对 docker-in-VM 负载(拉大镜像、容器内构建)太小会 OOM/卡死。→ WithMemory / WithCPUs

实测验证(dev180, msb 0.5.8)

  • 关 DNS rebind 后:VM 内 getent 能解析内网域名、docker pull 内网/portus 镜像成功(VM 启动参数可见 "rebind_protection":false)。
  • 设 8192/4 后:VM 内 MemTotal:8157564kB nproc:4,足以拉 4.5GB 镜像并在容器内构建。

兼容性

三个开关均默认不改变现有行为(不设 env → 走原 AllowAll() + SDK 默认规格)。gofmt clean。

…d VM size

Add three optional env-driven config knobs to the microsandbox driver,
all off/default unless explicitly set:

- MICROSANDBOX_DISABLE_DNS_REBIND_PROTECTION: when true, disables the
  microVM DNS rebind protection so guests can resolve names that point at
  private/internal IPs (e.g. an internal container registry). Needed for
  internal deployments that must docker pull / apt from private hosts.
- MICROSANDBOX_MEMORY_MIB / MICROSANDBOX_CPUS: override the microVM size
  above the SDK defaults (512MiB / 1 CPU), which are too small for
  docker-in-VM workloads such as pulling large images or building from a
  container (they OOM/stall). Zero means keep the SDK default.

Wires them into CreateSandbox via WithNetwork(DNS.RebindProtection),
WithMemory and WithCPUs.
@zhuanyongxigua zhuanyongxigua marked this pull request as draft June 23, 2026 12:45
…volume

- Loader scripts can now set per-run microVM size: memoryMib / cpus options
  on scheduler.shell / scheduler.exec / scheduler.agent thread down to the
  session and override the global MICROSANDBOX_MEMORY_MIB / MICROSANDBOX_CPUS
  defaults (0 = use default).
- Optionally mount a disk-backed named volume (kind=disk) at
  /var/lib/docker via MICROSANDBOX_DOCKER_DATA_SIZE_GB
  (+ MICROSANDBOX_DOCKER_DATA_PATH). One volume per session. The guest root
  is virtiofs, on which the kernel rejects overlayfs (docker's default
  storage driver); a disk-backed ext4 volume keeps docker's overlay off the
  virtiofs root. Uses SDK Mount.NamedWith(kind=disk), off by default.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant