]> git.proxmox.com Git - mirror_lxc.git/blob - doc/lxc.container.conf.sgml.in
confile: remove lxc.kmsg
[mirror_lxc.git] / doc / lxc.container.conf.sgml.in
1 <!--
2
3 lxc: linux Container library
4
5 (C) Copyright IBM Corp. 2007, 2008
6
7 Authors:
8 Daniel Lezcano <daniel.lezcano at free.fr>
9
10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Lesser General Public
12 License as published by the Free Software Foundation; either
13 version 2.1 of the License, or (at your option) any later version.
14
15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public
21 License along with this library; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23
24 -->
25
26 <!DOCTYPE refentry PUBLIC @docdtd@ [
27
28 <!ENTITY seealso SYSTEM "@builddir@/see_also.sgml">
29 ]>
30
31 <refentry>
32
33 <docinfo><date>@LXC_GENERATE_DATE@</date></docinfo>
34
35 <refmeta>
36 <refentrytitle>lxc.container.conf</refentrytitle>
37 <manvolnum>5</manvolnum>
38 </refmeta>
39
40 <refnamediv>
41 <refname>lxc.container.conf</refname>
42
43 <refpurpose>
44 LXC container configuration file
45 </refpurpose>
46 </refnamediv>
47
48 <refsect1>
49 <title>Description</title>
50
51 <para>
52 LXC is the well-known and heavily tested low-level Linux container
53 runtime. It is in active development since 2008 and has proven itself in
54 critical production environments world-wide. Some of its core contributors
55 are the same people that helped to implement various well-known
56 containerization features inside the Linux kernel.
57 </para>
58
59 <para>
60 LXC's main focus is system containers. That is, containers which offer an
61 environment as close as possible as the one you'd get from a VM but
62 without the overhead that comes with running a separate kernel and
63 simulating all the hardware.
64 </para>
65
66 <para>
67 This is achieved through a combination of kernel security features such as
68 namespaces, mandatory access control and control groups.
69 </para>
70
71 <para>
72 LXC has supports unprivileged containers. Unprivileged containers are
73 containers that are run without any privilege. This requires support for
74 user namespaces in the kernel that the container is run on. LXC was the
75 first runtime to support unprivileged containers after user namespaces
76 were merged into the mainline kernel.
77 </para>
78
79 <para>
80 In essence, user namespaces isolate given sets of UIDs and GIDs. This is
81 achieved by establishing a mapping between a range of UIDs and GIDs on the
82 host to a different (unprivileged) range of UIDs and GIDs in the
83 container. The kernel will translate this mapping in such a way that
84 inside the container all UIDs and GIDs appear as you would expect from the
85 host whereas on the host these UIDs and GIDs are in fact unprivileged. For
86 example, a process running as UID and GID 0 inside the container might
87 appear as UID and GID 100000 on the host. The implementation and working
88 details can be gathered from the corresponding user namespace man page.
89 UID and GID mappings can be defined with the <option>lxc.id_map</option>
90 key.
91 </para>
92
93 <para>
94 Linux containers are defined with a simple configuration file. Each
95 option in the configuration file has the form <command>key =
96 value</command> fitting in one line. The "#" character means the line is a
97 comment. List options, like capabilities and cgroups options, can be used
98 with no value to clear any previously defined values of that option.
99 </para>
100
101 <para>
102 LXC namespaces configuration keys by using single dots. This means complex
103 configuration keys such as <option>lxc.network</option> expose various
104 subkeys such as <option>lxc.network.type</option>,
105 <option>lxc.network.link</option>, <option>lxc.network.ipv6</option>, and
106 others for even more fine-grained configuration.
107 </para>
108
109 <refsect2>
110 <title>Configuration</title>
111 <para>
112 In order to ease administration of multiple related containers, it is
113 possible to have a container configuration file cause another file to be
114 loaded. For instance, network configuration can be defined in one common
115 file which is included by multiple containers. Then, if the containers
116 are moved to another host, only one file may need to be updated.
117 </para>
118
119 <variablelist>
120 <varlistentry>
121 <term>
122 <option>lxc.include</option>
123 </term>
124 <listitem>
125 <para>
126 Specify the file to be included. The included file must be
127 in the same valid lxc configuration file format.
128 </para>
129 </listitem>
130 </varlistentry>
131 </variablelist>
132 </refsect2>
133
134 <refsect2>
135 <title>Architecture</title>
136 <para>
137 Allows one to set the architecture for the container. For example, set a
138 32bits architecture for a container running 32bits binaries on a 64bits
139 host. This fixes the container scripts which rely on the architecture to
140 do some work like downloading the packages.
141 </para>
142
143 <variablelist>
144 <varlistentry>
145 <term>
146 <option>lxc.arch</option>
147 </term>
148 <listitem>
149 <para>
150 Specify the architecture for the container.
151 </para>
152 <para>
153 Some valid options are
154 <option>x86</option>,
155 <option>i686</option>,
156 <option>x86_64</option>,
157 <option>amd64</option>
158 </para>
159 </listitem>
160 </varlistentry>
161 </variablelist>
162
163 </refsect2>
164
165 <refsect2>
166 <title>Hostname</title>
167 <para>
168 The utsname section defines the hostname to be set for the container.
169 That means the container can set its own hostname without changing the
170 one from the system. That makes the hostname private for the container.
171 </para>
172 <variablelist>
173 <varlistentry>
174 <term>
175 <option>lxc.utsname</option>
176 </term>
177 <listitem>
178 <para>
179 specify the hostname for the container
180 </para>
181 </listitem>
182 </varlistentry>
183 </variablelist>
184 </refsect2>
185
186 <refsect2>
187 <title>Halt signal</title>
188 <para>
189 Allows one to specify signal name or number sent to the container's
190 init process to cleanly shutdown the container. Different init systems
191 could use different signals to perform clean shutdown sequence. This
192 option allows the signal to be specified in kill(1) fashion, e.g.
193 SIGPWR, SIGRTMIN+14, SIGRTMAX-10 or plain number. The default signal is
194 SIGPWR.
195 </para>
196 <variablelist>
197 <varlistentry>
198 <term>
199 <option>lxc.haltsignal</option>
200 </term>
201 <listitem>
202 <para>
203 specify the signal used to halt the container
204 </para>
205 </listitem>
206 </varlistentry>
207 </variablelist>
208 </refsect2>
209
210 <refsect2>
211 <title>Reboot signal</title>
212 <para>
213 Allows one to specify signal name or number to reboot the container.
214 This option allows signal to be specified in kill(1) fashion, e.g.
215 SIGTERM, SIGRTMIN+14, SIGRTMAX-10 or plain number. The default signal
216 is SIGINT.
217 </para>
218 <variablelist>
219 <varlistentry>
220 <term>
221 <option>lxc.rebootsignal</option>
222 </term>
223 <listitem>
224 <para>
225 specify the signal used to reboot the container
226 </para>
227 </listitem>
228 </varlistentry>
229 </variablelist>
230 </refsect2>
231
232 <refsect2>
233 <title>Stop signal</title>
234 <para>
235 Allows one to specify signal name or number to forcibly shutdown the
236 container. This option allows signal to be specified in kill(1) fashion,
237 e.g. SIGKILL, SIGRTMIN+14, SIGRTMAX-10 or plain number. The default
238 signal is SIGKILL.
239 </para>
240 <variablelist>
241 <varlistentry>
242 <term>
243 <option>lxc.stopsignal</option>
244 </term>
245 <listitem>
246 <para>
247 specify the signal used to stop the container
248 </para>
249 </listitem>
250 </varlistentry>
251 </variablelist>
252 </refsect2>
253
254 <refsect2>
255 <title>Init command</title>
256 <para>
257 Sets the command to use as the init system for the containers.
258
259 This option is ignored when using lxc-execute.
260
261 Defaults to: /sbin/init
262 </para>
263 <variablelist>
264 <varlistentry>
265 <term>
266 <option>lxc.init_cmd</option>
267 </term>
268 <listitem>
269 <para>
270 Absolute path from container rootfs to the binary to use as init.
271 </para>
272 </listitem>
273 </varlistentry>
274 </variablelist>
275 </refsect2>
276
277 <refsect2>
278 <title>Init ID</title>
279 <para>
280 Sets the UID/GID to use for the init system, and subsequent commands.
281 Note that using a non-root uid when booting a system container will
282 likely not work due to missing privileges. Setting the UID/GID is mostly
283 useful when running application container.
284
285 Defaults to: UID(0), GID(0)
286 </para>
287 <variablelist>
288 <varlistentry>
289 <term>
290 <option>lxc.init_uid</option>
291 </term>
292 <listitem>
293 <para>
294 UID to use for init.
295 </para>
296 </listitem>
297 </varlistentry>
298 <varlistentry>
299 <term>
300 <option>lxc.init_gid</option>
301 </term>
302 <listitem>
303 <para>
304 GID to use for init.
305 </para>
306 </listitem>
307 </varlistentry>
308 </variablelist>
309 </refsect2>
310
311 <refsect2>
312 <title>Ephemeral</title>
313 <para>
314 Allows one to specify whether a container will be destroyed on shutdown.
315 </para>
316 <variablelist>
317 <varlistentry>
318 <term>
319 <option>lxc.ephemeral</option>
320 </term>
321 <listitem>
322 <para>
323 The only allowed values are 0 and 1. Set this to 1 to destroy a
324 container on shutdown.
325 </para>
326 </listitem>
327 </varlistentry>
328 </variablelist>
329 </refsect2>
330
331 <refsect2>
332 <title>Network</title>
333 <para>
334 The network section defines how the network is virtualized in
335 the container. The network virtualization acts at layer
336 two. In order to use the network virtualization, parameters
337 must be specified to define the network interfaces of the
338 container. Several virtual interfaces can be assigned and used
339 in a container even if the system has only one physical
340 network interface.
341 </para>
342 <variablelist>
343 <varlistentry>
344 <term>
345 <option>lxc.network</option>
346 </term>
347 <listitem>
348 <para>
349 may be used without a value to clear all previous network options.
350 </para>
351 </listitem>
352 </varlistentry>
353 <varlistentry>
354 <term>
355 <option>lxc.network.[i].type</option>
356 </term>
357 <listitem>
358 <para>
359 specify what kind of network virtualization to be used
360 for the container.
361 Multiple networks can be specified by using an additional index
362 <option>i</option>
363 after all <option>lxc.network.*</option> keys. For example,
364 <option>lxc.network.0.type = veth</option> and
365 <option>lxc.network.1.type = veth</option> specify two different
366 networks of the same type. All keys sharing the same index
367 <option>i</option> will be treated as belonging to the same
368 network. For example, <option>lxc.network.0.link = br0</option>
369 will belong to <option>lxc.network.0.type</option>.
370 Currently, the different virtualization types can be:
371 </para>
372
373 <para>
374 <option>none:</option> will cause the container to share
375 the host's network namespace. This means the host
376 network devices are usable in the container. It also
377 means that if both the container and host have upstart as
378 init, 'halt' in a container (for instance) will shut down the
379 host.
380 </para>
381
382 <para>
383 <option>empty:</option> will create only the loopback
384 interface.
385 </para>
386
387 <para>
388 <option>veth:</option> a virtual ethernet pair
389 device is created with one side assigned to the container
390 and the other side attached to a bridge specified by
391 the <option>lxc.network.link</option> option.
392 If the bridge is not specified, then the veth pair device
393 will be created but not attached to any bridge.
394 Otherwise, the bridge has to be created on the system
395 before starting the container.
396 <command>lxc</command> won't handle any
397 configuration outside of the container.
398 By default, <command>lxc</command> chooses a name for the
399 network device belonging to the outside of the
400 container, but if you wish to handle
401 this name yourselves, you can tell <command>lxc</command>
402 to set a specific name with
403 the <option>lxc.network.veth.pair</option> option (except for
404 unprivileged containers where this option is ignored for security
405 reasons).
406 </para>
407
408 <para>
409 <option>vlan:</option> a vlan interface is linked with
410 the interface specified by
411 the <option>lxc.network.link</option> and assigned to
412 the container. The vlan identifier is specified with the
413 option <option>lxc.network.vlan.id</option>.
414 </para>
415
416 <para>
417 <option>macvlan:</option> a macvlan interface is linked
418 with the interface specified by
419 the <option>lxc.network.link</option> and assigned to
420 the container.
421 <option>lxc.network.macvlan.mode</option> specifies the
422 mode the macvlan will use to communicate between
423 different macvlan on the same upper device. The accepted
424 modes are <option>private</option>, <option>vepa</option>,
425 <option>bridge</option> and <option>passthru</option>.
426 In <option>private</option> mode, the device never
427 communicates with any other device on the same upper_dev (default).
428 In <option>vepa</option> mode, the new Virtual Ethernet Port
429 Aggregator (VEPA) mode, it assumes that the adjacent
430 bridge returns all frames where both source and
431 destination are local to the macvlan port, i.e. the
432 bridge is set up as a reflective relay. Broadcast
433 frames coming in from the upper_dev get flooded to all
434 macvlan interfaces in VEPA mode, local frames are not
435 delivered locally. In <option>bridge</option> mode, it
436 provides the behavior of a simple bridge between
437 different macvlan interfaces on the same port. Frames
438 from one interface to another one get delivered directly
439 and are not sent out externally. Broadcast frames get
440 flooded to all other bridge ports and to the external
441 interface, but when they come back from a reflective
442 relay, we don't deliver them again. Since we know all
443 the MAC addresses, the macvlan bridge mode does not
444 require learning or STP like the bridge module does. In
445 <option>passthru</option> mode, all frames received by
446 the physical interface are forwarded to the macvlan
447 interface. Only one macvlan interface in <option>passthru</option>
448 mode is possible for one physical interface.
449 </para>
450
451 <para>
452 <option>phys:</option> an already existing interface
453 specified by the <option>lxc.network.link</option> is
454 assigned to the container.
455 </para>
456 </listitem>
457 </varlistentry>
458
459 <varlistentry>
460 <term>
461 <option>lxc.network.[i].flags</option>
462 </term>
463 <listitem>
464 <para>
465 Specify an action to do for the network.
466 </para>
467
468 <para><option>up:</option> activates the interface.
469 </para>
470 </listitem>
471 </varlistentry>
472
473 <varlistentry>
474 <term>
475 <option>lxc.network.[i].link</option>
476 </term>
477 <listitem>
478 <para>
479 Specify the interface to be used for real network traffic.
480 </para>
481 </listitem>
482 </varlistentry>
483
484 <varlistentry>
485 <term>
486 <option>lxc.network.[i].mtu</option>
487 </term>
488 <listitem>
489 <para>
490 Specify the maximum transfer unit for this interface.
491 </para>
492 </listitem>
493 </varlistentry>
494
495 <varlistentry>
496 <term>
497 <option>lxc.network.[i].name</option>
498 </term>
499 <listitem>
500 <para>
501 The interface name is dynamically allocated, but if another name
502 is needed because the configuration files being used by the
503 container use a generic name, eg. eth0, this option will rename
504 the interface in the container.
505 </para>
506 </listitem>
507 </varlistentry>
508
509 <varlistentry>
510 <term>
511 <option>lxc.network.[i].hwaddr</option>
512 </term>
513 <listitem>
514 <para>
515 The interface mac address is dynamically allocated by default to
516 the virtual interface, but in some cases, this is needed to
517 resolve a mac address conflict or to always have the same
518 link-local ipv6 address. Any "x" in address will be replaced by
519 random value, this allows setting hwaddr templates.
520 </para>
521 </listitem>
522 </varlistentry>
523
524 <varlistentry>
525 <term>
526 <option>lxc.network.[i].ipv4</option>
527 </term>
528 <listitem>
529 <para>
530 Specify the ipv4 address to assign to the virtualized interface.
531 Several lines specify several ipv4 addresses. The address is in
532 format x.y.z.t/m, eg. 192.168.1.123/24.
533 </para>
534 </listitem>
535 </varlistentry>
536
537 <varlistentry>
538 <term>
539 <option>lxc.network.[i].ipv4.gateway</option>
540 </term>
541 <listitem>
542 <para>
543 Specify the ipv4 address to use as the gateway inside the
544 container. The address is in format x.y.z.t, eg. 192.168.1.123.
545
546 Can also have the special value <option>auto</option>,
547 which means to take the primary address from the bridge
548 interface (as specified by the
549 <option>lxc.network.link</option> option) and use that as
550 the gateway. <option>auto</option> is only available when
551 using the <option>veth</option> and
552 <option>macvlan</option> network types.
553 </para>
554 </listitem>
555 </varlistentry>
556
557
558 <varlistentry>
559 <term>
560 <option>lxc.network.[i].ipv6</option>
561 </term>
562 <listitem>
563 <para>
564 Specify the ipv6 address to assign to the virtualized
565 interface. Several lines specify several ipv6 addresses. The
566 address is in format x::y/m, eg.
567 2003:db8:1:0:214:1234:fe0b:3596/64
568 </para>
569 </listitem>
570 </varlistentry>
571
572 <varlistentry>
573 <term>
574 <option>lxc.network.[i].ipv6.gateway</option>
575 </term>
576 <listitem>
577 <para>
578 Specify the ipv6 address to use as the gateway inside the
579 container. The address is in format x::y, eg. 2003:db8:1:0::1
580
581 Can also have the special value <option>auto</option>,
582 which means to take the primary address from the bridge
583 interface (as specified by the
584 <option>lxc.network.link</option> option) and use that as
585 the gateway. <option>auto</option> is only available when
586 using the <option>veth</option> and
587 <option>macvlan</option> network types.
588 </para>
589 </listitem>
590 </varlistentry>
591
592 <varlistentry>
593 <term>
594 <option>lxc.network.[i].script.up</option>
595 </term>
596 <listitem>
597 <para>
598 Add a configuration option to specify a script to be
599 executed after creating and configuring the network used
600 from the host side. The following arguments are passed
601 to the script: container name and config section name
602 (net) Additional arguments depend on the config section
603 employing a script hook; the following are used by the
604 network system: execution context (up), network type
605 (empty/veth/macvlan/phys), Depending on the network
606 type, other arguments may be passed:
607 veth/macvlan/phys. And finally (host-sided) device name.
608 </para>
609 <para>
610 Standard output from the script is logged at debug level.
611 Standard error is not logged, but can be captured by the
612 hook redirecting its standard error to standard output.
613 </para>
614 </listitem>
615 </varlistentry>
616
617 <varlistentry>
618 <term>
619 <option>lxc.network.[i].script.down</option>
620 </term>
621 <listitem>
622 <para>
623 Add a configuration option to specify a script to be
624 executed before destroying the network used from the
625 host side. The following arguments are passed to the
626 script: container name and config section name (net)
627 Additional arguments depend on the config section
628 employing a script hook; the following are used by the
629 network system: execution context (down), network type
630 (empty/veth/macvlan/phys), Depending on the network
631 type, other arguments may be passed:
632 veth/macvlan/phys. And finally (host-sided) device name.
633 </para>
634 <para>
635 Standard output from the script is logged at debug level.
636 Standard error is not logged, but can be captured by the
637 hook redirecting its standard error to standard output.
638 </para>
639 </listitem>
640 </varlistentry>
641 </variablelist>
642 </refsect2>
643
644 <refsect2>
645 <title>New pseudo tty instance (devpts)</title>
646 <para>
647 For stricter isolation the container can have its own private
648 instance of the pseudo tty.
649 </para>
650 <variablelist>
651 <varlistentry>
652 <term>
653 <option>lxc.pts</option>
654 </term>
655 <listitem>
656 <para>
657 If set, the container will have a new pseudo tty
658 instance, making this private to it. The value specifies
659 the maximum number of pseudo ttys allowed for a pts
660 instance (this limitation is not implemented yet).
661 </para>
662 </listitem>
663 </varlistentry>
664 </variablelist>
665 </refsect2>
666
667 <refsect2>
668 <title>Container system console</title>
669 <para>
670 If the container is configured with a root filesystem and the
671 inittab file is setup to use the console, you may want to specify
672 where the output of this console goes.
673 </para>
674 <variablelist>
675 <varlistentry>
676 <term>
677 <option>lxc.console.logfile</option>
678 </term>
679 <listitem>
680 <para>
681 Specify a path to a file where the console output will
682 be written.
683 </para>
684 </listitem>
685 </varlistentry>
686 <varlistentry>
687 <term>
688 <option>lxc.console</option>
689 </term>
690 <listitem>
691 <para>
692 Specify a path to a device to which the console will be
693 attached. The keyword 'none' will simply disable the
694 console. Note, when specifying 'none' and creating a device node
695 for the console in the container at /dev/console or bind-mounting
696 the hosts's /dev/console into the container at /dev/console the
697 container will have direct access to the hosts's /dev/console.
698 This is dangerous when the container has write access to the
699 device and should thus be used with caution.
700 </para>
701 </listitem>
702 </varlistentry>
703 </variablelist>
704 </refsect2>
705
706 <refsect2>
707 <title>Console through the ttys</title>
708 <para>
709 This option is useful if the container is configured with a root
710 filesystem and the inittab file is setup to launch a getty on the
711 ttys. The option specifies the number of ttys to be available for
712 the container. The number of gettys in the inittab file of the
713 container should not be greater than the number of ttys specified
714 in this option, otherwise the excess getty sessions will die and
715 respawn indefinitely giving annoying messages on the console or in
716 <filename>/var/log/messages</filename>.
717 </para>
718 <variablelist>
719 <varlistentry>
720 <term>
721 <option>lxc.tty</option>
722 </term>
723 <listitem>
724 <para>
725 Specify the number of tty to make available to the
726 container.
727 </para>
728 </listitem>
729 </varlistentry>
730 </variablelist>
731 </refsect2>
732
733 <refsect2>
734 <title>Console devices location</title>
735 <para>
736 LXC consoles are provided through Unix98 PTYs created on the
737 host and bind-mounted over the expected devices in the container.
738 By default, they are bind-mounted over <filename>/dev/console</filename>
739 and <filename>/dev/ttyN</filename>. This can prevent package upgrades
740 in the guest. Therefore you can specify a directory location (under
741 <filename>/dev</filename> under which LXC will create the files and
742 bind-mount over them. These will then be symbolically linked to
743 <filename>/dev/console</filename> and <filename>/dev/ttyN</filename>.
744 A package upgrade can then succeed as it is able to remove and replace
745 the symbolic links.
746 </para>
747 <variablelist>
748 <varlistentry>
749 <term>
750 <option>lxc.devttydir</option>
751 </term>
752 <listitem>
753 <para>
754 Specify a directory under <filename>/dev</filename>
755 under which to create the container console devices. Note that LXC
756 will move any bind-mounts or device nodes for /dev/console into
757 this directory.
758 </para>
759 </listitem>
760 </varlistentry>
761 </variablelist>
762 </refsect2>
763
764 <refsect2>
765 <title>/dev directory</title>
766 <para>
767 By default, lxc creates a few symbolic links (fd,stdin,stdout,stderr)
768 in the container's <filename>/dev</filename> directory but does not
769 automatically create device node entries. This allows the container's
770 <filename>/dev</filename> to be set up as needed in the container
771 rootfs. If lxc.autodev is set to 1, then after mounting the container's
772 rootfs LXC will mount a fresh tmpfs under <filename>/dev</filename>
773 (limited to 500k) and fill in a minimal set of initial devices.
774 This is generally required when starting a container containing
775 a "systemd" based "init" but may be optional at other times. Additional
776 devices in the containers /dev directory may be created through the
777 use of the <option>lxc.hook.autodev</option> hook.
778 </para>
779 <variablelist>
780 <varlistentry>
781 <term>
782 <option>lxc.autodev</option>
783 </term>
784 <listitem>
785 <para>
786 Set this to 0 to stop LXC from mounting and populating a minimal
787 <filename>/dev</filename> when starting the container.
788 </para>
789 </listitem>
790 </varlistentry>
791 </variablelist>
792 </refsect2>
793
794 <refsect2>
795 <title>Mount points</title>
796 <para>
797 The mount points section specifies the different places to be
798 mounted. These mount points will be private to the container
799 and won't be visible by the processes running outside of the
800 container. This is useful to mount /etc, /var or /home for
801 examples.
802 </para>
803 <para>
804 NOTE - LXC will generally ensure that mount targets and relative
805 bind-mount sources are properly confined under the container
806 root, to avoid attacks involving over-mounting host directories
807 and files. (Symbolic links in absolute mount sources are ignored)
808 However, if the container configuration first mounts a directory which
809 is under the control of the container user, such as /home/joe, into
810 the container at some <filename>path</filename>, and then mounts
811 under <filename>path</filename>, then a TOCTTOU attack would be
812 possible where the container user modifies a symbolic link under
813 his home directory at just the right time.
814 </para>
815 <variablelist>
816 <varlistentry>
817 <term>
818 <option>lxc.mount</option>
819 </term>
820 <listitem>
821 <para>
822 specify a file location in
823 the <filename>fstab</filename> format, containing the
824 mount information. The mount target location can and in
825 most cases should be a relative path, which will become
826 relative to the mounted container root. For instance,
827 </para>
828 <programlisting>
829 proc proc proc nodev,noexec,nosuid 0 0
830 </programlisting>
831 <para>
832 Will mount a proc filesystem under the container's /proc,
833 regardless of where the root filesystem comes from. This
834 is resilient to block device backed filesystems as well as
835 container cloning.
836 </para>
837 <para>
838 Note that when mounting a filesystem from an
839 image file or block device the third field (fs_vfstype)
840 cannot be auto as with
841 <citerefentry>
842 <refentrytitle>mount</refentrytitle>
843 <manvolnum>8</manvolnum>
844 </citerefentry>
845 but must be explicitly specified.
846 </para>
847 </listitem>
848 </varlistentry>
849
850 <varlistentry>
851 <term>
852 <option>lxc.mount.entry</option>
853 </term>
854 <listitem>
855 <para>
856 specify a mount point corresponding to a line in the
857 fstab format.
858
859 Moreover lxc add two options to mount.
860 <option>optional</option> don't fail if mount does not work.
861 <option>create=dir</option> or <option>create=file</option>
862 to create dir (or file) when the point will be mounted.
863 </para>
864 </listitem>
865 </varlistentry>
866
867 <varlistentry>
868 <term>
869 <option>lxc.mount.auto</option>
870 </term>
871 <listitem>
872 <para>
873 specify which standard kernel file systems should be
874 automatically mounted. This may dramatically simplify
875 the configuration. The file systems are:
876 </para>
877 <itemizedlist>
878 <listitem>
879 <para>
880 <option>proc:mixed</option> (or <option>proc</option>):
881 mount <filename>/proc</filename> as read-write, but
882 remount <filename>/proc/sys</filename> and
883 <filename>/proc/sysrq-trigger</filename> read-only
884 for security / container isolation purposes.
885 </para>
886 </listitem>
887 <listitem>
888 <para>
889 <option>proc:rw</option>: mount
890 <filename>/proc</filename> as read-write
891 </para>
892 </listitem>
893 <listitem>
894 <para>
895 <option>sys:mixed</option> (or <option>sys</option>):
896 mount <filename>/sys</filename> as read-only but with
897 /sys/devices/virtual/net writable.
898 </para>
899 </listitem>
900 <listitem>
901 <para>
902 <option>sys:ro</option>:
903 mount <filename>/sys</filename> as read-only
904 for security / container isolation purposes.
905 </para>
906 </listitem>
907 <listitem>
908 <para>
909 <option>sys:rw</option>: mount
910 <filename>/sys</filename> as read-write
911 </para>
912 </listitem>
913 <listitem>
914 <para>
915 <option>cgroup:mixed</option>:
916 mount a tmpfs to <filename>/sys/fs/cgroup</filename>,
917 create directories for all hierarchies to which
918 the container is added, create subdirectories
919 there with the name of the cgroup, and bind-mount
920 the container's own cgroup into that directory.
921 The container will be able to write to its own
922 cgroup directory, but not the parents, since they
923 will be remounted read-only.
924 </para>
925 </listitem>
926 <listitem>
927 <para>
928 <option>cgroup:ro</option>: similar to
929 <option>cgroup:mixed</option>, but everything will
930 be mounted read-only.
931 </para>
932 </listitem>
933 <listitem>
934 <para>
935 <option>cgroup:rw</option>: similar to
936 <option>cgroup:mixed</option>, but everything will
937 be mounted read-write. Note that the paths leading
938 up to the container's own cgroup will be writable,
939 but will not be a cgroup filesystem but just part
940 of the tmpfs of <filename>/sys/fs/cgroup</filename>
941 </para>
942 </listitem>
943 <listitem>
944 <para>
945 <option>cgroup</option> (without specifier):
946 defaults to <option>cgroup:rw</option> if the
947 container retains the CAP_SYS_ADMIN capability,
948 <option>cgroup:mixed</option> otherwise.
949 </para>
950 </listitem>
951 <listitem>
952 <para>
953 <option>cgroup-full:mixed</option>:
954 mount a tmpfs to <filename>/sys/fs/cgroup</filename>,
955 create directories for all hierarchies to which
956 the container is added, bind-mount the hierarchies
957 from the host to the container and make everything
958 read-only except the container's own cgroup. Note
959 that compared to <option>cgroup</option>, where
960 all paths leading up to the container's own cgroup
961 are just simple directories in the underlying
962 tmpfs, here
963 <filename>/sys/fs/cgroup/$hierarchy</filename>
964 will contain the host's full cgroup hierarchy,
965 albeit read-only outside the container's own cgroup.
966 This may leak quite a bit of information into the
967 container.
968 </para>
969 </listitem>
970 <listitem>
971 <para>
972 <option>cgroup-full:ro</option>: similar to
973 <option>cgroup-full:mixed</option>, but everything
974 will be mounted read-only.
975 </para>
976 </listitem>
977 <listitem>
978 <para>
979 <option>cgroup-full:rw</option>: similar to
980 <option>cgroup-full:mixed</option>, but everything
981 will be mounted read-write. Note that in this case,
982 the container may escape its own cgroup. (Note also
983 that if the container has CAP_SYS_ADMIN support
984 and can mount the cgroup filesystem itself, it may
985 do so anyway.)
986 </para>
987 </listitem>
988 <listitem>
989 <para>
990 <option>cgroup-full</option> (without specifier):
991 defaults to <option>cgroup-full:rw</option> if the
992 container retains the CAP_SYS_ADMIN capability,
993 <option>cgroup-full:mixed</option> otherwise.
994 </para>
995 </listitem>
996 </itemizedlist>
997 <para>
998 If cgroup namespaces are enabled, then any <option>cgroup</option>
999 auto-mounting request will be ignored, since the container can
1000 mount the filesystems itself, and automounting can confuse the
1001 container init.
1002 </para>
1003 <para>
1004 Note that if automatic mounting of the cgroup filesystem
1005 is enabled, the tmpfs under
1006 <filename>/sys/fs/cgroup</filename> will always be
1007 mounted read-write (but for the <option>:mixed</option>
1008 and <option>:ro</option> cases, the individual
1009 hierarchies,
1010 <filename>/sys/fs/cgroup/$hierarchy</filename>, will be
1011 read-only). This is in order to work around a quirk in
1012 Ubuntu's
1013 <citerefentry>
1014 <refentrytitle>mountall</refentrytitle>
1015 <manvolnum>8</manvolnum>
1016 </citerefentry>
1017 command that will cause containers to wait for user
1018 input at boot if
1019 <filename>/sys/fs/cgroup</filename> is mounted read-only
1020 and the container can't remount it read-write due to a
1021 lack of CAP_SYS_ADMIN.
1022 </para>
1023 <para>
1024 Examples:
1025 </para>
1026 <programlisting>
1027 lxc.mount.auto = proc sys cgroup
1028 lxc.mount.auto = proc:rw sys:rw cgroup-full:rw
1029 </programlisting>
1030 </listitem>
1031 </varlistentry>
1032
1033 </variablelist>
1034 </refsect2>
1035
1036 <refsect2>
1037 <title>Root file system</title>
1038 <para>
1039 The root file system of the container can be different than that
1040 of the host system.
1041 </para>
1042 <variablelist>
1043 <varlistentry>
1044 <term>
1045 <option>lxc.rootfs</option>
1046 </term>
1047 <listitem>
1048 <para>
1049 specify the root file system for the container. It can
1050 be an image file, a directory or a block device. If not
1051 specified, the container shares its root file system
1052 with the host.
1053 </para>
1054 <para>
1055 For directory or simple block-device backed containers,
1056 a pathname can be used. If the rootfs is backed by a nbd
1057 device, then <filename>nbd:file:1</filename> specifies that
1058 <filename>file</filename> should be attached to a nbd device,
1059 and partition 1 should be mounted as the rootfs.
1060 <filename>nbd:file</filename> specifies that the nbd device
1061 itself should be mounted. <filename>overlayfs:/lower:/upper</filename>
1062 specifies that the rootfs should be an overlay with <filename>/upper</filename>
1063 being mounted read-write over a read-only mount of <filename>/lower</filename>.
1064 <filename>aufs:/lower:/upper</filename> does the same using aufs in place
1065 of overlayfs. For both <filename>overlayfs</filename> and
1066 <filename>aufs</filename> multiple <filename>/lower</filename>
1067 directories can be specified. <filename>loop:/file</filename> tells lxc to attach
1068 <filename>/file</filename> to a loop device and mount the loop device.
1069 </para>
1070 </listitem>
1071 </varlistentry>
1072
1073 <varlistentry>
1074 <term>
1075 <option>lxc.rootfs.mount</option>
1076 </term>
1077 <listitem>
1078 <para>
1079 where to recursively bind <option>lxc.rootfs</option>
1080 before pivoting. This is to ensure success of the
1081 <citerefentry>
1082 <refentrytitle><command>pivot_root</command></refentrytitle>
1083 <manvolnum>8</manvolnum>
1084 </citerefentry>
1085 syscall. Any directory suffices, the default should
1086 generally work.
1087 </para>
1088 </listitem>
1089 </varlistentry>
1090
1091 <varlistentry>
1092 <term>
1093 <option>lxc.rootfs.options</option>
1094 </term>
1095 <listitem>
1096 <para>
1097 extra mount options to use when mounting the rootfs.
1098 </para>
1099 </listitem>
1100 </varlistentry>
1101
1102 <varlistentry>
1103 <term>
1104 <option>lxc.rootfs.backend</option>
1105 </term>
1106 <listitem>
1107 <para>
1108 specify the rootfs backend type to use, for instance 'dir' or
1109 'zfs'. While this can be guessed by lxc at container startup,
1110 doing so takes time. Specifying it here avoids extra
1111 processing.
1112 </para>
1113 </listitem>
1114 </varlistentry>
1115
1116 </variablelist>
1117 </refsect2>
1118
1119 <refsect2>
1120 <title>Control group</title>
1121 <para>
1122 The control group section contains the configuration for the
1123 different subsystem. <command>lxc</command> does not check the
1124 correctness of the subsystem name. This has the disadvantage
1125 of not detecting configuration errors until the container is
1126 started, but has the advantage of permitting any future
1127 subsystem.
1128 </para>
1129 <variablelist>
1130 <varlistentry>
1131 <term>
1132 <option>lxc.cgroup.[subsystem name]</option>
1133 </term>
1134 <listitem>
1135 <para>
1136 specify the control group value to be set. The
1137 subsystem name is the literal name of the control group
1138 subsystem. The permitted names and the syntax of their
1139 values is not dictated by LXC, instead it depends on the
1140 features of the Linux kernel running at the time the
1141 container is started,
1142 eg. <option>lxc.cgroup.cpuset.cpus</option>
1143 </para>
1144 </listitem>
1145 </varlistentry>
1146 </variablelist>
1147 </refsect2>
1148
1149 <refsect2>
1150 <title>Capabilities</title>
1151 <para>
1152 The capabilities can be dropped in the container if this one
1153 is run as root.
1154 </para>
1155 <variablelist>
1156 <varlistentry>
1157 <term>
1158 <option>lxc.cap.drop</option>
1159 </term>
1160 <listitem>
1161 <para>
1162 Specify the capability to be dropped in the container. A
1163 single line defining several capabilities with a space
1164 separation is allowed. The format is the lower case of
1165 the capability definition without the "CAP_" prefix,
1166 eg. CAP_SYS_MODULE should be specified as
1167 sys_module. See
1168 <citerefentry>
1169 <refentrytitle><command>capabilities</command></refentrytitle>
1170 <manvolnum>7</manvolnum>
1171 </citerefentry>.
1172 If used with no value, lxc will clear any drop capabilities
1173 specified up to this point.
1174 </para>
1175 </listitem>
1176 </varlistentry>
1177 <varlistentry>
1178 <term>
1179 <option>lxc.cap.keep</option>
1180 </term>
1181 <listitem>
1182 <para>
1183 Specify the capability to be kept in the container. All other
1184 capabilities will be dropped. When a special value of "none" is
1185 encountered, lxc will clear any keep capabilities specified up
1186 to this point. A value of "none" alone can be used to drop all
1187 capabilities.
1188 </para>
1189 </listitem>
1190 </varlistentry>
1191 </variablelist>
1192 </refsect2>
1193
1194 <refsect2>
1195 <title>Resource limits</title>
1196 <para>
1197 The soft and hard resource limits for the container can be changed.
1198 Unprivileged containers can only lower them. Resources which are not
1199 explicitly specified will be inherited.
1200 </para>
1201 <variablelist>
1202 <varlistentry>
1203 <term>
1204 <option>lxc.limit.[limit name]</option>
1205 </term>
1206 <listitem>
1207 <para>
1208 Specify the resource limit to be set. A limit is specified as two
1209 colon separated values which are either numeric or the word
1210 'unlimited'. A single value can be used as a shortcut to set both
1211 soft and hard limit to the same value. The permitted names the
1212 "RLIMIT_" resource names in lowercase without the "RLIMIT_"
1213 prefix, eg. RLIMIT_NOFILE should be specified as "nofile". See
1214 <citerefentry>
1215 <refentrytitle><command>setrlimit</command></refentrytitle>
1216 <manvolnum>2</manvolnum>
1217 </citerefentry>.
1218 If used with no value, lxc will clear the resource limit
1219 specified up to this point. A resource with no explicitly
1220 configured limitation will be inherited from the process starting
1221 up the container.
1222 </para>
1223 </listitem>
1224 </varlistentry>
1225 </variablelist>
1226 </refsect2>
1227
1228 <refsect2>
1229 <title>Apparmor profile</title>
1230 <para>
1231 If lxc was compiled and installed with apparmor support, and the host
1232 system has apparmor enabled, then the apparmor profile under which the
1233 container should be run can be specified in the container
1234 configuration. The default is <command>lxc-container-default-cgns</command>
1235 if the host kernel is cgroup namespace aware, or
1236 <command>lxc-container-default</command> othewise.
1237 </para>
1238 <variablelist>
1239 <varlistentry>
1240 <term>
1241 <option>lxc.aa_profile</option>
1242 </term>
1243 <listitem>
1244 <para>
1245 Specify the apparmor profile under which the container should
1246 be run. To specify that the container should be unconfined,
1247 use
1248 </para>
1249 <programlisting>lxc.aa_profile = unconfined</programlisting>
1250 <para>
1251 If the apparmor profile should remain unchanged (i.e. if you
1252 are nesting containers and are already confined), then use
1253 </para>
1254 <programlisting>lxc.aa_profile = unchanged</programlisting>
1255 </listitem>
1256 </varlistentry>
1257 <varlistentry>
1258 <term>
1259 <option>lxc.aa_allow_incomplete</option>
1260 </term>
1261 <listitem>
1262 <para>
1263 Apparmor profiles are pathname based. Therefore many file
1264 restrictions require mount restrictions to be effective against
1265 a determined attacker. However, these mount restrictions are not
1266 yet implemented in the upstream kernel. Without the mount
1267 restrictions, the apparmor profiles still protect against accidental
1268 damager.
1269 </para>
1270 <para>
1271 If this flag is 0 (default), then the container will not be
1272 started if the kernel lacks the apparmor mount features, so that a
1273 regression after a kernel upgrade will be detected. To start the
1274 container under partial apparmor protection, set this flag to 1.
1275 </para>
1276 </listitem>
1277 </varlistentry>
1278 </variablelist>
1279 </refsect2>
1280
1281 <refsect2>
1282 <title>SELinux context</title>
1283 <para>
1284 If lxc was compiled and installed with SELinux support, and the host
1285 system has SELinux enabled, then the SELinux context under which the
1286 container should be run can be specified in the container
1287 configuration. The default is <command>unconfined_t</command>,
1288 which means that lxc will not attempt to change contexts.
1289 See @DATADIR@/lxc/selinux/lxc.te for an example policy and more
1290 information.
1291 </para>
1292 <variablelist>
1293 <varlistentry>
1294 <term>
1295 <option>lxc.se_context</option>
1296 </term>
1297 <listitem>
1298 <para>
1299 Specify the SELinux context under which the container should
1300 be run or <command>unconfined_t</command>. For example
1301 </para>
1302 <programlisting>lxc.se_context = system_u:system_r:lxc_t:s0:c22</programlisting>
1303 </listitem>
1304 </varlistentry>
1305 </variablelist>
1306 </refsect2>
1307
1308 <refsect2>
1309 <title>Seccomp configuration</title>
1310 <para>
1311 A container can be started with a reduced set of available
1312 system calls by loading a seccomp profile at startup. The
1313 seccomp configuration file must begin with a version number
1314 on the first line, a policy type on the second line, followed
1315 by the configuration.
1316 </para>
1317 <para>
1318 Versions 1 and 2 are currently supported. In version 1, the
1319 policy is a simple whitelist. The second line therefore must
1320 read "whitelist", with the rest of the file containing one (numeric)
1321 sycall number per line. Each syscall number is whitelisted,
1322 while every unlisted number is blacklisted for use in the container
1323 </para>
1324
1325 <para>
1326 In version 2, the policy may be blacklist or whitelist,
1327 supports per-rule and per-policy default actions, and supports
1328 per-architecture system call resolution from textual names.
1329 </para>
1330 <para>
1331 An example blacklist policy, in which all system calls are
1332 allowed except for mknod, which will simply do nothing and
1333 return 0 (success), looks like:
1334 </para>
1335
1336 <programlisting>
1337 2
1338 blacklist
1339 mknod errno 0
1340 </programlisting>
1341
1342 <variablelist>
1343 <varlistentry>
1344 <term>
1345 <option>lxc.seccomp</option>
1346 </term>
1347 <listitem>
1348 <para>
1349 Specify a file containing the seccomp configuration to
1350 load before the container starts.
1351 </para>
1352 </listitem>
1353 </varlistentry>
1354 </variablelist>
1355 </refsect2>
1356
1357 <refsect2>
1358 <title>PR_SET_NO_NEW_PRIVS</title>
1359 <para>
1360 With PR_SET_NO_NEW_PRIVS active execve() promises not to grant
1361 privileges to do anything that could not have been done without
1362 the execve() call (for example, rendering the set-user-ID and
1363 set-group-ID mode bits, and file capabilities non-functional).
1364 Once set, this bit cannot be unset. The setting of this bit is
1365 inherited by children created by fork() and clone(), and preserved
1366 across execve().
1367 Note that PR_SET_NO_NEW_PRIVS is applied after the container has
1368 changed into its intended AppArmor profile or SElinux context.
1369 </para>
1370 <variablelist>
1371 <varlistentry>
1372 <term>
1373 <option>lxc.no_new_privs</option>
1374 </term>
1375 <listitem>
1376 <para>
1377 Specify whether the PR_SET_NO_NEW_PRIVS flag should be set for the
1378 container. Set to 1 to activate.
1379 </para>
1380 </listitem>
1381 </varlistentry>
1382 </variablelist>
1383 </refsect2>
1384
1385 <refsect2>
1386 <title>UID mappings</title>
1387 <para>
1388 A container can be started in a private user namespace with
1389 user and group id mappings. For instance, you can map userid
1390 0 in the container to userid 200000 on the host. The root
1391 user in the container will be privileged in the container,
1392 but unprivileged on the host. Normally a system container
1393 will want a range of ids, so you would map, for instance,
1394 user and group ids 0 through 20,000 in the container to the
1395 ids 200,000 through 220,000.
1396 </para>
1397 <variablelist>
1398 <varlistentry>
1399 <term>
1400 <option>lxc.id_map</option>
1401 </term>
1402 <listitem>
1403 <para>
1404 Four values must be provided. First a character, either
1405 'u', or 'g', to specify whether user or group ids are
1406 being mapped. Next is the first userid as seen in the
1407 user namespace of the container. Next is the userid as
1408 seen on the host. Finally, a range indicating the number
1409 of consecutive ids to map.
1410 </para>
1411 </listitem>
1412 </varlistentry>
1413 </variablelist>
1414 </refsect2>
1415
1416 <refsect2>
1417 <title>Container hooks</title>
1418 <para>
1419 Container hooks are programs or scripts which can be executed
1420 at various times in a container's lifetime.
1421 </para>
1422 <para>
1423 When a container hook is executed, information is passed both
1424 as command line arguments and through environment variables.
1425 The arguments are:
1426 <itemizedlist>
1427 <listitem><para> Container name. </para></listitem>
1428 <listitem><para> Section (always 'lxc'). </para></listitem>
1429 <listitem><para> The hook type (i.e. 'clone' or 'pre-mount'). </para></listitem>
1430 <listitem><para> Additional arguments. In the
1431 case of the clone hook, any extra arguments passed to
1432 lxc-clone will appear as further arguments to the hook.
1433 In the case of the stop hook, paths to filedescriptors
1434 for each of the container's namespaces along with their types
1435 are passed. </para></listitem>
1436 </itemizedlist>
1437 The following environment variables are set:
1438 <itemizedlist>
1439 <listitem><para> LXC_NAME: is the container's name. </para></listitem>
1440 <listitem><para> LXC_ROOTFS_MOUNT: the path to the mounted root filesystem. </para></listitem>
1441 <listitem><para> LXC_CONFIG_FILE: the path to the container configuration file. </para></listitem>
1442 <listitem><para> LXC_SRC_NAME: in the case of the clone hook, this is the original container's name. </para></listitem>
1443 <listitem><para> LXC_ROOTFS_PATH: this is the lxc.rootfs entry for the container. Note this is likely not where the mounted rootfs is to be found, use LXC_ROOTFS_MOUNT for that. </para></listitem>
1444 </itemizedlist>
1445 </para>
1446 <para>
1447 Standard output from the hooks is logged at debug level.
1448 Standard error is not logged, but can be captured by the
1449 hook redirecting its standard error to standard output.
1450 </para>
1451 <variablelist>
1452 <varlistentry>
1453 <term>
1454 <option>lxc.hook.pre-start</option>
1455 </term>
1456 <listitem>
1457 <para>
1458 A hook to be run in the host's namespace before the
1459 container ttys, consoles, or mounts are up.
1460 </para>
1461 </listitem>
1462 </varlistentry>
1463 </variablelist>
1464 <variablelist>
1465 <varlistentry>
1466 <term>
1467 <option>lxc.hook.pre-mount</option>
1468 </term>
1469 <listitem>
1470 <para>
1471 A hook to be run in the container's fs namespace but before
1472 the rootfs has been set up. This allows for manipulation
1473 of the rootfs, i.e. to mount an encrypted filesystem. Mounts
1474 done in this hook will not be reflected on the host (apart from
1475 mounts propagation), so they will be automatically cleaned up
1476 when the container shuts down.
1477 </para>
1478 </listitem>
1479 </varlistentry>
1480 </variablelist>
1481 <variablelist>
1482 <varlistentry>
1483 <term>
1484 <option>lxc.hook.mount</option>
1485 </term>
1486 <listitem>
1487 <para>
1488 A hook to be run in the container's namespace after
1489 mounting has been done, but before the pivot_root.
1490 </para>
1491 </listitem>
1492 </varlistentry>
1493 </variablelist>
1494 <variablelist>
1495 <varlistentry>
1496 <term>
1497 <option>lxc.hook.autodev</option>
1498 </term>
1499 <listitem>
1500 <para>
1501 A hook to be run in the container's namespace after
1502 mounting has been done and after any mount hooks have
1503 run, but before the pivot_root, if
1504 <option>lxc.autodev</option> == 1.
1505 The purpose of this hook is to assist in populating the
1506 /dev directory of the container when using the autodev
1507 option for systemd based containers. The container's /dev
1508 directory is relative to the
1509 ${<option>LXC_ROOTFS_MOUNT</option>} environment
1510 variable available when the hook is run.
1511 </para>
1512 </listitem>
1513 </varlistentry>
1514 </variablelist>
1515 <variablelist>
1516 <varlistentry>
1517 <term>
1518 <option>lxc.hook.start</option>
1519 </term>
1520 <listitem>
1521 <para>
1522 A hook to be run in the container's namespace immediately
1523 before executing the container's init. This requires the
1524 program to be available in the container.
1525 </para>
1526 </listitem>
1527 </varlistentry>
1528 </variablelist>
1529 <variablelist>
1530 <varlistentry>
1531 <term>
1532 <option>lxc.hook.stop</option>
1533 </term>
1534 <listitem>
1535 <para>
1536 A hook to be run in the host's namespace with references
1537 to the container's namespaces after the container has been shut
1538 down. For each namespace an extra argument is passed to the hook
1539 containing the namespace's type and a filename that can be used to
1540 obtain a file descriptor to the corresponding namespace, separated
1541 by a colon. The type is the name as it would appear in the
1542 <filename>/proc/PID/ns</filename> directory.
1543 For instance for the mount namespace the argument usually looks
1544 like <filename>mnt:/proc/PID/fd/12</filename>.
1545 </para>
1546 </listitem>
1547 </varlistentry>
1548 </variablelist>
1549 <variablelist>
1550 <varlistentry>
1551 <term>
1552 <option>lxc.hook.post-stop</option>
1553 </term>
1554 <listitem>
1555 <para>
1556 A hook to be run in the host's namespace after the
1557 container has been shut down.
1558 </para>
1559 </listitem>
1560 </varlistentry>
1561 </variablelist>
1562 <variablelist>
1563 <varlistentry>
1564 <term>
1565 <option>lxc.hook.clone</option>
1566 </term>
1567 <listitem>
1568 <para>
1569 A hook to be run when the container is cloned to a new one.
1570 See <citerefentry><refentrytitle><command>lxc-clone</command></refentrytitle>
1571 <manvolnum>1</manvolnum></citerefentry> for more information.
1572 </para>
1573 </listitem>
1574 </varlistentry>
1575 </variablelist>
1576 <variablelist>
1577 <varlistentry>
1578 <term>
1579 <option>lxc.hook.destroy</option>
1580 </term>
1581 <listitem>
1582 <para>
1583 A hook to be run when the container is destroyed.
1584 </para>
1585 </listitem>
1586 </varlistentry>
1587 </variablelist>
1588 </refsect2>
1589
1590 <refsect2>
1591 <title>Container hooks Environment Variables</title>
1592 <para>
1593 A number of environment variables are made available to the startup
1594 hooks to provide configuration information and assist in the
1595 functioning of the hooks. Not all variables are valid in all
1596 contexts. In particular, all paths are relative to the host system
1597 and, as such, not valid during the <option>lxc.hook.start</option> hook.
1598 </para>
1599 <variablelist>
1600 <varlistentry>
1601 <term>
1602 <option>LXC_NAME</option>
1603 </term>
1604 <listitem>
1605 <para>
1606 The LXC name of the container. Useful for logging messages
1607 in common log environments. [<option>-n</option>]
1608 </para>
1609 </listitem>
1610 </varlistentry>
1611 </variablelist>
1612 <variablelist>
1613 <varlistentry>
1614 <term>
1615 <option>LXC_CONFIG_FILE</option>
1616 </term>
1617 <listitem>
1618 <para>
1619 Host relative path to the container configuration file. This
1620 gives the container to reference the original, top level,
1621 configuration file for the container in order to locate any
1622 additional configuration information not otherwise made
1623 available. [<option>-f</option>]
1624 </para>
1625 </listitem>
1626 </varlistentry>
1627 </variablelist>
1628 <variablelist>
1629 <varlistentry>
1630 <term>
1631 <option>LXC_CONSOLE</option>
1632 </term>
1633 <listitem>
1634 <para>
1635 The path to the console output of the container if not NULL.
1636 [<option>-c</option>] [<option>lxc.console</option>]
1637 </para>
1638 </listitem>
1639 </varlistentry>
1640 </variablelist>
1641 <variablelist>
1642 <varlistentry>
1643 <term>
1644 <option>LXC_CONSOLE_LOGPATH</option>
1645 </term>
1646 <listitem>
1647 <para>
1648 The path to the console log output of the container if not NULL.
1649 [<option>-L</option>]
1650 </para>
1651 </listitem>
1652 </varlistentry>
1653 </variablelist>
1654 <variablelist>
1655 <varlistentry>
1656 <term>
1657 <option>LXC_ROOTFS_MOUNT</option>
1658 </term>
1659 <listitem>
1660 <para>
1661 The mount location to which the container is initially bound.
1662 This will be the host relative path to the container rootfs
1663 for the container instance being started and is where changes
1664 should be made for that instance.
1665 [<option>lxc.rootfs.mount</option>]
1666 </para>
1667 </listitem>
1668 </varlistentry>
1669 </variablelist>
1670 <variablelist>
1671 <varlistentry>
1672 <term>
1673 <option>LXC_ROOTFS_PATH</option>
1674 </term>
1675 <listitem>
1676 <para>
1677 The host relative path to the container root which has been
1678 mounted to the rootfs.mount location.
1679 [<option>lxc.rootfs</option>]
1680 </para>
1681 </listitem>
1682 </varlistentry>
1683 </variablelist>
1684 <variablelist>
1685 <varlistentry>
1686 <term>
1687 <option>LXC_SRC_NAME</option>
1688 </term>
1689 <listitem>
1690 <para>
1691 Only for the clone hook. Is set to the original container name.
1692 </para>
1693 </listitem>
1694 </varlistentry>
1695 </variablelist>
1696 <variablelist>
1697 <varlistentry>
1698 <term>
1699 <option>LXC_TARGET</option>
1700 </term>
1701 <listitem>
1702 <para>
1703 Only for the stop hook. Is set to "stop" for a container
1704 shutdown or "reboot" for a container reboot.
1705 </para>
1706 </listitem>
1707 </varlistentry>
1708 </variablelist>
1709 <variablelist>
1710 <varlistentry>
1711 <term>
1712 <option>LXC_CGNS_AWARE</option>
1713 </term>
1714 <listitem>
1715 <para>
1716 If unset, then this version of lxc is not aware of cgroup
1717 namespaces. If set, it will be set to 1, and lxc is aware
1718 of cgroup namespaces. Note this does not guarantee that
1719 cgroup namespaces are enabled in the kernel. This is used
1720 by the lxcfs mount hook.
1721 </para>
1722 </listitem>
1723 </varlistentry>
1724 </variablelist>
1725 </refsect2>
1726 <refsect2>
1727 <title>Logging</title>
1728 <para>
1729 Logging can be configured on a per-container basis. By default,
1730 depending upon how the lxc package was compiled, container startup
1731 is logged only at the ERROR level, and logged to a file named after
1732 the container (with '.log' appended) either under the container path,
1733 or under @LOGPATH@.
1734 </para>
1735 <para>
1736 Both the default log level and the log file can be specified in the
1737 container configuration file, overriding the default behavior. Note
1738 that the configuration file entries can in turn be overridden by the
1739 command line options to <command>lxc-start</command>.
1740 </para>
1741 <variablelist>
1742 <varlistentry>
1743 <term>
1744 <option>lxc.loglevel</option>
1745 </term>
1746 <listitem>
1747 <para>
1748 The level at which to log. The log level is an integer in
1749 the range of 0..8 inclusive, where a lower number means more
1750 verbose debugging. In particular 0 = trace, 1 = debug, 2 =
1751 info, 3 = notice, 4 = warn, 5 = error, 6 = critical, 7 =
1752 alert, and 8 = fatal. If unspecified, the level defaults
1753 to 5 (error), so that only errors and above are logged.
1754 </para>
1755 <para>
1756 Note that when a script (such as either a hook script or a
1757 network interface up or down script) is called, the script's
1758 standard output is logged at level 1, debug.
1759 </para>
1760 </listitem>
1761 </varlistentry>
1762 <varlistentry>
1763 <term>
1764 <option>lxc.logfile</option>
1765 </term>
1766 <listitem>
1767 <para>
1768 The file to which logging info should be written.
1769 </para>
1770 </listitem>
1771 </varlistentry>
1772 <varlistentry>
1773 <term>
1774 <option>lxc.syslog</option>
1775 </term>
1776 <listitem>
1777 <para>
1778 Send logging info to syslog. It respects the log level defined in
1779 <command>lxc.loglevel</command>. The argument should be the syslog
1780 facility to use, valid ones are: daemon, local0, local1, local2,
1781 local3, local4, local5, local5, local6, local7.
1782 </para>
1783 </listitem>
1784 </varlistentry>
1785 </variablelist>
1786 </refsect2>
1787
1788 <refsect2>
1789 <title>Autostart</title>
1790 <para>
1791 The autostart options support marking which containers should be
1792 auto-started and in what order. These options may be used by LXC tools
1793 directly or by external tooling provided by the distributions.
1794 </para>
1795
1796 <variablelist>
1797 <varlistentry>
1798 <term>
1799 <option>lxc.start.auto</option>
1800 </term>
1801 <listitem>
1802 <para>
1803 Whether the container should be auto-started.
1804 Valid values are 0 (off) and 1 (on).
1805 </para>
1806 </listitem>
1807 </varlistentry>
1808 <varlistentry>
1809 <term>
1810 <option>lxc.start.delay</option>
1811 </term>
1812 <listitem>
1813 <para>
1814 How long to wait (in seconds) after the container is
1815 started before starting the next one.
1816 </para>
1817 </listitem>
1818 </varlistentry>
1819 <varlistentry>
1820 <term>
1821 <option>lxc.start.order</option>
1822 </term>
1823 <listitem>
1824 <para>
1825 An integer used to sort the containers when auto-starting
1826 a series of containers at once.
1827 </para>
1828 </listitem>
1829 </varlistentry>
1830 <varlistentry>
1831 <term>
1832 <option>lxc.monitor.unshare</option>
1833 </term>
1834 <listitem>
1835 <para>
1836 If not zero the mount namespace will be unshared from the host
1837 before initializing the container (before running any pre-start
1838 hooks). This requires the CAP_SYS_ADMIN capability at startup.
1839 Default is 0.
1840 </para>
1841 </listitem>
1842 </varlistentry>
1843 <varlistentry>
1844 <term>
1845 <option>lxc.group</option>
1846 </term>
1847 <listitem>
1848 <para>
1849 A multi-value key (can be used multiple times) to put the
1850 container in a container group. Those groups can then be
1851 used (amongst other things) to start a series of related
1852 containers.
1853 </para>
1854 </listitem>
1855 </varlistentry>
1856 </variablelist>
1857 </refsect2>
1858
1859 <refsect2>
1860 <title>Autostart and System Boot</title>
1861 <para>
1862 Each container can be part of any number of groups or no group at all.
1863 Two groups are special. One is the NULL group, i.e. the container does
1864 not belong to any group. The other group is the "onboot" group.
1865 </para>
1866
1867 <para>
1868 When the system boots with the LXC service enabled, it will first
1869 attempt to boot any containers with lxc.start.auto == 1 that is a member
1870 of the "onboot" group. The startup will be in order of lxc.start.order.
1871 If an lxc.start.delay has been specified, that delay will be honored
1872 before attempting to start the next container to give the current
1873 container time to begin initialization and reduce overloading the host
1874 system. After starting the members of the "onboot" group, the LXC system
1875 will proceed to boot containers with lxc.start.auto == 1 which are not
1876 members of any group (the NULL group) and proceed as with the onboot
1877 group.
1878 </para>
1879
1880 </refsect2>
1881
1882 <refsect2>
1883 <title>Container Environment</title>
1884 <para>
1885 If you want to pass environment variables into the container (that
1886 is, environment variables which will be available to init and all of
1887 its descendents), you can use <command>lxc.environment</command>
1888 parameters to do so. Be careful that you do not pass in anything
1889 sensitive; any process in the container which doesn't have its
1890 environment scrubbed will have these variables available to it, and
1891 environment variables are always available via
1892 <command>/proc/PID/environ</command>.
1893 </para>
1894
1895 <para>
1896 This configuration parameter can be specified multiple times; once
1897 for each environment variable you wish to configure.
1898 </para>
1899
1900 <variablelist>
1901 <varlistentry>
1902 <term>
1903 <option>lxc.environment</option>
1904 </term>
1905 <listitem>
1906 <para>
1907 Specify an environment variable to pass into the container.
1908 Example:
1909 </para>
1910 <programlisting>
1911 lxc.environment = APP_ENV=production
1912 lxc.environment = SYSLOG_SERVER=192.0.2.42
1913 </programlisting>
1914 </listitem>
1915 </varlistentry>
1916 </variablelist>
1917 </refsect2>
1918
1919 </refsect1>
1920
1921 <refsect1>
1922 <title>Examples</title>
1923 <para>
1924 In addition to the few examples given below, you will find
1925 some other examples of configuration file in @DOCDIR@/examples
1926 </para>
1927 <refsect2>
1928 <title>Network</title>
1929 <para>This configuration sets up a container to use a veth pair
1930 device with one side plugged to a bridge br0 (which has been
1931 configured before on the system by the administrator). The
1932 virtual network device visible in the container is renamed to
1933 eth0.</para>
1934 <programlisting>
1935 lxc.utsname = myhostname
1936 lxc.network.type = veth
1937 lxc.network.flags = up
1938 lxc.network.link = br0
1939 lxc.network.name = eth0
1940 lxc.network.hwaddr = 4a:49:43:49:79:bf
1941 lxc.network.ipv4 = 10.2.3.5/24 10.2.3.255
1942 lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3597
1943 </programlisting>
1944 </refsect2>
1945
1946 <refsect2>
1947 <title>UID/GID mapping</title>
1948 <para>This configuration will map both user and group ids in the
1949 range 0-9999 in the container to the ids 100000-109999 on the host.
1950 </para>
1951 <programlisting>
1952 lxc.id_map = u 0 100000 10000
1953 lxc.id_map = g 0 100000 10000
1954 </programlisting>
1955 </refsect2>
1956
1957 <refsect2>
1958 <title>Control group</title>
1959 <para>This configuration will setup several control groups for
1960 the application, cpuset.cpus restricts usage of the defined cpu,
1961 cpus.share prioritize the control group, devices.allow makes
1962 usable the specified devices.</para>
1963 <programlisting>
1964 lxc.cgroup.cpuset.cpus = 0,1
1965 lxc.cgroup.cpu.shares = 1234
1966 lxc.cgroup.devices.deny = a
1967 lxc.cgroup.devices.allow = c 1:3 rw
1968 lxc.cgroup.devices.allow = b 8:0 rw
1969 </programlisting>
1970 </refsect2>
1971
1972 <refsect2>
1973 <title>Complex configuration</title>
1974 <para>This example show a complex configuration making a complex
1975 network stack, using the control groups, setting a new hostname,
1976 mounting some locations and a changing root file system.</para>
1977 <programlisting>
1978 lxc.utsname = complex
1979 lxc.network.0.type = veth
1980 lxc.network.0.flags = up
1981 lxc.network.0.link = br0
1982 lxc.network.0.hwaddr = 4a:49:43:49:79:bf
1983 lxc.network.0.ipv4 = 10.2.3.5/24 10.2.3.255
1984 lxc.network.0.ipv6 = 2003:db8:1:0:214:1234:fe0b:3597
1985 lxc.network.0.ipv6 = 2003:db8:1:0:214:5432:feab:3588
1986 lxc.network.1.type = macvlan
1987 lxc.network.1.flags = up
1988 lxc.network.1.link = eth0
1989 lxc.network.1.hwaddr = 4a:49:43:49:79:bd
1990 lxc.network.1.ipv4 = 10.2.3.4/24
1991 lxc.network.1.ipv4 = 192.168.10.125/24
1992 lxc.network.1.ipv6 = 2003:db8:1:0:214:1234:fe0b:3596
1993 lxc.network.2.type = phys
1994 lxc.network.2.flags = up
1995 lxc.network.2.link = dummy0
1996 lxc.network.2.hwaddr = 4a:49:43:49:79:ff
1997 lxc.network.2.ipv4 = 10.2.3.6/24
1998 lxc.network.2.ipv6 = 2003:db8:1:0:214:1234:fe0b:3297
1999 lxc.cgroup.cpuset.cpus = 0,1
2000 lxc.cgroup.cpu.shares = 1234
2001 lxc.cgroup.devices.deny = a
2002 lxc.cgroup.devices.allow = c 1:3 rw
2003 lxc.cgroup.devices.allow = b 8:0 rw
2004 lxc.mount = /etc/fstab.complex
2005 lxc.mount.entry = /lib /root/myrootfs/lib none ro,bind 0 0
2006 lxc.rootfs = /mnt/rootfs.complex
2007 lxc.cap.drop = sys_module mknod setuid net_raw
2008 lxc.cap.drop = mac_override
2009 </programlisting>
2010 </refsect2>
2011
2012 </refsect1>
2013
2014 <refsect1>
2015 <title>See Also</title>
2016 <simpara>
2017 <citerefentry>
2018 <refentrytitle><command>chroot</command></refentrytitle>
2019 <manvolnum>1</manvolnum>
2020 </citerefentry>,
2021
2022 <citerefentry>
2023 <refentrytitle><command>pivot_root</command></refentrytitle>
2024 <manvolnum>8</manvolnum>
2025 </citerefentry>,
2026
2027 <citerefentry>
2028 <refentrytitle><filename>fstab</filename></refentrytitle>
2029 <manvolnum>5</manvolnum>
2030 </citerefentry>,
2031
2032 <citerefentry>
2033 <refentrytitle><filename>capabilities</filename></refentrytitle>
2034 <manvolnum>7</manvolnum>
2035 </citerefentry>
2036 </simpara>
2037 </refsect1>
2038
2039 &seealso;
2040
2041 <refsect1>
2042 <title>Author</title>
2043 <para>Daniel Lezcano <email>daniel.lezcano@free.fr</email></para>
2044 </refsect1>
2045
2046 </refentry>
2047
2048 <!-- Keep this comment at the end of the file
2049 Local variables:
2050 mode: sgml
2051 sgml-omittag:t
2052 sgml-shorttag:t
2053 sgml-minimize-attributes:nil
2054 sgml-always-quote-attributes:t
2055 sgml-indent-step:2
2056 sgml-indent-data:t
2057 sgml-parent-document:nil
2058 sgml-default-dtd-file:nil
2059 sgml-exposed-tags:nil
2060 sgml-local-catalogs:nil
2061 sgml-local-ecat-files:nil
2062 End:
2063 -->