Condukt.Sandbox.Microsandbox (Condukt v3.0.0)

Copy Markdown View Source

Sandbox backend powered by the microsandbox microVM runtime through a Rust NIF.

By default this sandbox boots an OCI image, bind-mounts the current host workspace at /workspace, and runs commands there. That makes it suitable for the built-in coding tools while keeping command execution inside the guest VM instead of the host process.

Initializing

{:ok, sandbox} =
  Condukt.Sandbox.new(Condukt.Sandbox.Microsandbox,
    image: "ubuntu:24.04"
  )

{:ok, sandbox} =
  Condukt.Sandbox.new(Condukt.Sandbox.Microsandbox,
    image: "ghcr.io/myorg/elixir-dev:latest",
    cwd: "/repo",
    workspace_host: File.cwd!(),
    mounts: [{"/tmp/cache", "/cache", :readwrite}]
  )

Options

  • :image - OCI image to boot. Defaults to "ubuntu:24.04".
  • :cwd - Guest working directory. Defaults to /workspace.
  • :workspace_host - Host directory to bind-mount at :cwd. Defaults to File.cwd!/0.
  • :mount_workspace - Whether to add the default workspace bind mount. Defaults to true.
  • :mounts - Additional construction-time bind mounts as {host, guest} or {host, guest, :readonly | :readwrite} tuples.
  • :shell - Shell used for exec/3. Defaults to /bin/bash.
  • :cpus - Virtual CPU count. Defaults to 2.
  • :memory - Guest memory in MiB. Defaults to 1024.
  • :env - Sandbox-wide environment variables.
  • :replace_existing - Replace a leftover sandbox with the same session id. Defaults to true.

Current limits

  • Runtime mount/3 is not supported because microsandbox only exposes volume configuration at sandbox creation time.
  • glob/3 and grep/3 operate on host-backed bind mounts. Paths outside a bind mount return {:error, :not_supported} for those operations.
  • start_process/4 runs a command detached inside the guest, so it outlives the exec call that started it, but not the microVM, which ends with this sandbox. The image needs setsid from util-linux.
  • Condukt.Sandbox.NetworkPolicy remains Kubernetes-specific. This backend does not translate it yet.