nixpkgs-suyu/doc/builders/images/ocitools.xml

62 lines
2.5 KiB
XML
Raw Normal View History

2019-08-30 15:46:38 +02:00
<section xmlns="http://docbook.org/ns/docbook"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xi="http://www.w3.org/2001/XInclude"
xml:id="sec-pkgs-ociTools">
<title>pkgs.ociTools</title>
<para>
2019-09-18 22:12:54 +02:00
<varname>pkgs.ociTools</varname> is a set of functions for creating containers according to the <link xlink:href="https://github.com/opencontainers/runtime-spec">OCI container specification v1.0.0</link>. Beyond that it makes no assumptions about the container runner you choose to use to run the created container.
2019-08-30 15:46:38 +02:00
</para>
<section xml:id="ssec-pkgs-ociTools-buildContainer">
<title>buildContainer</title>
<para>
2019-09-18 22:12:54 +02:00
This function creates a simple OCI container that runs a single command inside of it. An OCI container consists of a <varname>config.json</varname> and a rootfs directory.The nix store of the container will contain all referenced dependencies of the given command.
2019-08-30 15:46:38 +02:00
</para>
<para>
2019-09-18 22:12:54 +02:00
The parameters of <varname>buildContainer</varname> with an example value are described below:
2019-08-30 15:46:38 +02:00
</para>
<example xml:id='ex-ociTools-buildContainer'>
<title>Build Container</title>
<programlisting>
buildContainer {
args = [ (with pkgs; writeScript "run.sh" ''
2019-08-30 15:46:38 +02:00
#!${bash}/bin/bash
exec ${bash}/bin/bash
'').outPath ]; <co xml:id='ex-ociTools-buildContainer-1' />
2019-08-30 15:46:38 +02:00
mounts = {
"/data" = {
type = "none";
source = "/var/lib/mydata";
options = [ "bind" ];
};
};<co xml:id='ex-ociTools-buildContainer-2' />
readonly = false; <co xml:id='ex-ociTools-buildContainer-3' />
}
</programlisting>
2019-08-30 15:46:38 +02:00
<calloutlist>
<callout arearefs='ex-ociTools-buildContainer-1'>
<para>
2019-09-18 22:12:54 +02:00
<varname>args</varname> specifies a set of arguments to run inside the container. This is the only required argument for <varname>buildContainer</varname>. All referenced packages inside the derivation will be made available inside the container
2019-08-30 15:46:38 +02:00
</para>
</callout>
<callout arearefs='ex-ociTools-buildContainer-2'>
<para>
2019-09-18 22:12:54 +02:00
<varname>mounts</varname> specifies additional mount points chosen by the user. By default only a minimal set of necessary filesystems are mounted into the container (e.g procfs, cgroupfs)
2019-08-30 15:46:38 +02:00
</para>
</callout>
<callout arearefs='ex-ociTools-buildContainer-3'>
<para>
2019-09-18 22:12:54 +02:00
<varname>readonly</varname> makes the container's rootfs read-only if it is set to true. The default value is false <literal>false</literal>.
2019-08-30 15:46:38 +02:00
</para>
</callout>
</calloutlist>
</example>
</section>
</section>