OCI runtime spec types and runc command wrapper
OCaml 93.9%
Dune 2.2%
Other 3.9%
10 1 0

Clone this repository

https://tangled.org/gazagnaire.org/ocaml-runc https://tangled.org/did:plc:jhift2vwcxhou52p3sewcrpx/ocaml-runc
git@git.recoil.org:gazagnaire.org/ocaml-runc git@git.recoil.org:did:plc:jhift2vwcxhou52p3sewcrpx/ocaml-runc

For self-hosted knots, clone URLs may differ based on your setup.

Download tar.gz
README.md

runc#

OCaml bindings for runc, the OCI container runtime.

Provides typed representations of the OCI runtime specification (config.json) and functions to invoke runc commands for container lifecycle management.

Installation#

opam install runc

Usage#

Eio_main.run @@ fun env ->
Eio.Switch.run @@ fun sw ->

(* Create runc command context *)
let runc = Runc.Command.create ~sw ~env () in

(* Define the container process *)
let process = Runc.Process.v [ "/bin/echo"; "hello" ] in

(* Define the root filesystem *)
let root = Runc.Root.v "rootfs" in

(* Build the OCI config *)
let config = Runc.Config.v ~process ~root () in

(* Write config.json to bundle directory *)
let json = Runc.Config.to_json config in
(* ... write json to bundle/config.json ... *)

(* Run the container *)
let container = Runc.Command.run ~id:"test" ~bundle:"./bundle" runc in

(* Clean up *)
let _ = Runc.Command.delete runc container in
()

Modules#

  • Runc.User - User specification (uid, gid)
  • Runc.Mount - Mount specification with common defaults
  • Runc.Namespace - Linux namespace types
  • Runc.Capability - Linux capabilities
  • Runc.Capabilities - Capability sets
  • Runc.Rlimit - Resource limits
  • Runc.Process - Process specification
  • Runc.Root - Root filesystem specification
  • Runc.Linux - Linux-specific configuration
  • Runc.Config - OCI runtime configuration (config.json)
  • Runc.Command - runc command wrapper

Licence#

ISC License. See LICENSE.md for details.