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 toFile.cwd!/0.:mount_workspace- Whether to add the default workspace bind mount. Defaults totrue.:mounts- Additional construction-time bind mounts as{host, guest}or{host, guest, :readonly | :readwrite}tuples.:shell- Shell used forexec/3. Defaults to/bin/bash.:cpus- Virtual CPU count. Defaults to2.:memory- Guest memory in MiB. Defaults to1024.:env- Sandbox-wide environment variables.:replace_existing- Replace a leftover sandbox with the same session id. Defaults totrue.
Current limits
- Runtime
mount/3is not supported becausemicrosandboxonly exposes volume configuration at sandbox creation time. glob/3andgrep/3operate on host-backed bind mounts. Paths outside a bind mount return{:error, :not_supported}for those operations.start_process/4runs 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 needssetsidfrom util-linux.Condukt.Sandbox.NetworkPolicyremains Kubernetes-specific. This backend does not translate it yet.