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 defaultsRunc.Namespace- Linux namespace typesRunc.Capability- Linux capabilitiesRunc.Capabilities- Capability setsRunc.Rlimit- Resource limitsRunc.Process- Process specificationRunc.Root- Root filesystem specificationRunc.Linux- Linux-specific configurationRunc.Config- OCI runtime configuration (config.json)Runc.Command- runc command wrapper
Related Work#
- runc - Reference OCI runtime
- OCI Runtime Spec - The specification
- OBuilder - OCaml build sandbox using runc
- Albatross - MirageOS unikernel orchestration
Licence#
ISC License. See LICENSE.md for details.