Ocaml-lxc (binding to Linux Containers) - progress report, looking for feedback and contributors

Hello everyone,

I’m writing to share the progress on ocaml-lxc, check if anyone’s interested, and also looking for feedback or potential contributions


ocaml-lxc is an OCaml binding to Linux Containers C API

The high level exposed design aims to largely match the one of go-lxc, but with adjustments to make it more ergonomic and closer to idiomatic OCaml


  • Low level API
    • Low level internal API (lxc_c.ml, lxc_c.mli) which matches closely with C API has been completed, and offers (almost) complete coverage of the C API
  • High level API
    • Core parts of the high level exposed API (lxc.ml, lxc.mli) have been completed, you can see here for feature set comparison to go-lxc
  • Documentation
    • You can see here for the documentation of the high level API. I have not actually written the documention yet, so this is only useful for examining the library structure atm.


This section is more useful if you’re planning to contribute. Feel free to skip.

  • Code generation
    • Cinaps is used to generate glue code for both C and OCaml side to access lxc_container C struct function pointer fields. See code_gen/gen.cinaps for all the core code generation code.
  • Stubs generation
    • Stubs generation via Ctypes is used to offer high confidence that things are done correctly at compile time. See code_gen/ffi_bindings.ml, code_gen/ffi_types.ml, code_gen/types.ml, and code_gen/stubs_gen.ml.
  • C glue code
    • Additional glue code is added to handle things like conditional compilation based on LXC version, working around anonymous struct (not supported by Ctypes), etc. See code_gen/lxc_glue.c and code_gen/lxc_glue.h.
  • Low level API
    • Low level API ties all the loose ends together, provides a fairly direct mapping to the C API, and is the main abstraction layer used by the higher level API. See src/lxc_c.ml and src/lxc_c.mli.
  • High level API
    • High level API introduces more abstraction, masking C objects, and has a more hierarchical structure compared to the flat structure used by lower level API. See src/lxc.ml and src/lxc.mli.

What I’m looking for

  • If you’re interested in using the library, please feel free to provide feedback on the API design
    • e.g. what can be improved, what you don’t like, what’s missing
  • If you’re interested in contributing, please feel free to reach out to me to coordinate etc. Following is the rough todo list I have atm
    • Add test code (copy go-lxc’s test suite)
    • Add examples
    • API documentation
    • Document build flow architecture (specifically how dune fits into it maybe)
    • Document code architecture


A lot of the core bits of ocaml-lxc are done and took way too much time, looking for people to help out with the remaining really tedious yet crucial parts. And get sanity checks from people who may become users of ocaml-lxc.


This is just a aggregated list of the links above