Bsdkrun (bsdkrun_ex v0.3.0)

Copy Markdown View Source

Elixir SDK for bsdkrun — a Firecracker-style microVM launcher for BSD and Linux guests on macOS and Linux, built on libkrun.

The SDK is a thin, stateless wrapper around the bsdkrun binary: it builds argv, shells out via System.cmd/3, and parses JSON output. It has one runtime dependency (:jason).

{:ok, box} = Bsdkrun.create(os: :linux, image: "alpine")
{:ok, res} = Bsdkrun.exec(box, ["uname", "-a"])
IO.puts(Bsdkrun.Types.Result.text(res))
:ok = Bsdkrun.stop(box)

Or, with the bang variants, as one |> chain — see Bsdkrun.Sandbox for the chaining rules:

Bsdkrun.create!(os: :linux, image: "alpine")
|> Bsdkrun.exec!(["uname", "-a"])
|> Bsdkrun.Types.Result.text()
|> IO.puts()

The binary is resolved (in order) from Bsdkrun.Binary.set_binary_path/1, the $BSDKRUN_BIN env var, bsdkrun on $PATH, or an in-repo dev build. See Bsdkrun.Binary.

Modules

Summary

Functions

create(opts)

See Bsdkrun.Sandbox.create/1.

create!(opts)

See Bsdkrun.Sandbox.create!/1.

exec(ref, command, opts \\ [])

See Bsdkrun.Sandbox.exec/3.

exec!(ref, command, opts \\ [])

See Bsdkrun.Sandbox.exec!/3.

get(id)

See Bsdkrun.Sandbox.get/1.

list(opts \\ [])

See Bsdkrun.Sandbox.list/1.

logs(ref, opts \\ [])

See Bsdkrun.Sandbox.logs/2.

logs!(ref, opts \\ [])

See Bsdkrun.Sandbox.logs!/2.

remove(ref, opts \\ [])

See Bsdkrun.Sandbox.remove/2.

remove!(ref, opts \\ [])

See Bsdkrun.Sandbox.remove!/2.

set_binary_path(path)

See Bsdkrun.Binary.set_binary_path/1.

start(ref)

See Bsdkrun.Sandbox.start/1.

start!(ref)

See Bsdkrun.Sandbox.start!/1.

stop(ref)

See Bsdkrun.Sandbox.stop/1.

stop!(ref)

See Bsdkrun.Sandbox.stop!/1.