···1+<section xmlns="http://docbook.org/ns/docbook"
2+ xmlns:xlink="http://www.w3.org/1999/xlink"
3+ xmlns:xi="http://www.w3.org/2001/XInclude"
4+ xml:id="sec-pkgs-ociTools">
5+ <title>pkgs.ociTools</title>
6+7+ <para>
8+ <varname>pkgs.ociTools</varname> is a set of functions for creating
9+ containers according to the
10+ <link xlink:href="https://github.com/opencontainers/runtime-spec">OCI
11+ container specification v1.0.0</link>. Beyond that it makes no assumptions
12+ about the container runner you choose to use to run the created container.
13+ </para>
14+15+ <section xml:id="ssec-pkgs-ociTools-buildContainer">
16+ <title>buildContainer</title>
17+18+ <para>
19+ This function creates a simple OCI container that runs a single command
20+ inside of it. An OCI container consists of a <varname>config.json</varname>
21+ and a rootfs directory.The nix store of the container will contain all
22+ referenced dependencies of the given command.
23+ </para>
24+25+ <para>
26+ The parameters of <varname>buildContainer</varname> with an example value
27+ are described below:
28+ </para>
29+30+ <example xml:id='ex-ociTools-buildContainer'>
31+ <title>Build Container</title>
32+<programlisting>
33+buildContainer {
34+ cmd = with pkgs; writeScript "run.sh" ''
35+ #!${bash}/bin/bash
36+ ${coreutils}/bin/exec ${bash}/bin/bash
37+ ''; <co xml:id='ex-ociTools-buildContainer-1' />
38+39+ mounts = {
40+ "/data" = {
41+ type = "none";
42+ source = "/var/lib/mydata";
43+ options = [ "bind" ];
44+ };
45+ };<co xml:id='ex-ociTools-buildContainer-2' />
46+47+ readonly = false; <co xml:id='ex-ociTools-buildContainer-3' />
48+}
49+50+ </programlisting>
51+ <calloutlist>
52+ <callout arearefs='ex-ociTools-buildContainer-1'>
53+ <para>
54+ <varname>cmd</varname> specifies the program to run inside the container.
55+ This is the only required argument for <varname>buildContainer</varname>.
56+ All referenced packages inside the derivation will be made available
57+ inside the container
58+ </para>
59+ </callout>
60+ <callout arearefs='ex-ociTools-buildContainer-2'>
61+ <para>
62+ <varname>mounts</varname> specifies additional mount points chosen by the
63+ user. By default only a minimal set of necessary filesystems are mounted
64+ into the container (e.g procfs, cgroupfs)
65+ </para>
66+ </callout>
67+ <callout arearefs='ex-ociTools-buildContainer-3'>
68+ <para>
69+ <varname>readonly</varname> makes the container's rootfs read-only if it is set to true.
70+ The default value is false <literal>false</literal>.
71+ </para>
72+ </callout>
73+ </calloutlist>
74+ </example>
75+ </section>
76+</section>