]> git.proxmox.com Git - mirror_lxc.git/blob - doc/lxc.container.conf.sgml.in
network: Adds support host side veth device static routes
[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 support for 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.idmap</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 use single dots. This means complex
103 configuration keys such as <option>lxc.net.0</option> expose various
104 subkeys such as <option>lxc.net.0.type</option>,
105 <option>lxc.net.0.link</option>, <option>lxc.net.0.ipv6.address</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.uts.name</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.signal.halt</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.signal.reboot</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.signal.stop</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 </para>
259 <variablelist>
260 <varlistentry>
261 <term>
262 <option>lxc.execute.cmd</option>
263 </term>
264 <listitem>
265 <para>
266 Absolute path from container rootfs to the binary to run by default. This
267 mostly makes sense for <command>lxc-execute</command>.
268 </para>
269 </listitem>
270 </varlistentry>
271 </variablelist>
272 <variablelist>
273 <varlistentry>
274 <term>
275 <option>lxc.init.cmd</option>
276 </term>
277 <listitem>
278 <para>
279 Absolute path from container rootfs to the binary to use as init. This
280 mostly makes sense for <command>lxc-start</command>. Default is <command>/sbin/init</command>.
281 </para>
282 </listitem>
283 </varlistentry>
284 </variablelist>
285 </refsect2>
286
287 <refsect2>
288 <title>Init working directory</title>
289 <para>
290 Sets the absolute path inside the container as the working directory for the containers.
291 LXC will switch to this directory before executing init.
292 </para>
293 <variablelist>
294 <varlistentry>
295 <term>
296 <option>lxc.init.cwd</option>
297 </term>
298 <listitem>
299 <para>
300 Absolute path inside the container to use as the working directory.
301 </para>
302 </listitem>
303 </varlistentry>
304 </variablelist>
305 </refsect2>
306
307 <refsect2>
308 <title>Init ID</title>
309 <para>
310 Sets the UID/GID to use for the init system, and subsequent commands.
311 Note that using a non-root UID when booting a system container will
312 likely not work due to missing privileges. Setting the UID/GID is mostly
313 useful when running application containers.
314
315 Defaults to: UID(0), GID(0)
316 </para>
317 <variablelist>
318 <varlistentry>
319 <term>
320 <option>lxc.init.uid</option>
321 </term>
322 <listitem>
323 <para>
324 UID to use for init.
325 </para>
326 </listitem>
327 </varlistentry>
328 <varlistentry>
329 <term>
330 <option>lxc.init.gid</option>
331 </term>
332 <listitem>
333 <para>
334 GID to use for init.
335 </para>
336 </listitem>
337 </varlistentry>
338 </variablelist>
339 </refsect2>
340
341 <refsect2>
342 <title>Proc</title>
343 <para>
344 Configure proc filesystem for the container.
345 </para>
346 <variablelist>
347 <varlistentry>
348 <term>
349 <option>lxc.proc.[proc file name]</option>
350 </term>
351 <listitem>
352 <para>
353 Specify the proc file name to be set. The file names available
354 are those listed under /proc/PID/.
355 Example:
356 </para>
357 <programlisting>
358 lxc.proc.oom_score_adj = 10
359 </programlisting>
360 </listitem>
361 </varlistentry>
362 </variablelist>
363 </refsect2>
364
365 <refsect2>
366 <title>Ephemeral</title>
367 <para>
368 Allows one to specify whether a container will be destroyed on shutdown.
369 </para>
370 <variablelist>
371 <varlistentry>
372 <term>
373 <option>lxc.ephemeral</option>
374 </term>
375 <listitem>
376 <para>
377 The only allowed values are 0 and 1. Set this to 1 to destroy a
378 container on shutdown.
379 </para>
380 </listitem>
381 </varlistentry>
382 </variablelist>
383 </refsect2>
384
385 <refsect2>
386 <title>Network</title>
387 <para>
388 The network section defines how the network is virtualized in
389 the container. The network virtualization acts at layer
390 two. In order to use the network virtualization, parameters
391 must be specified to define the network interfaces of the
392 container. Several virtual interfaces can be assigned and used
393 in a container even if the system has only one physical
394 network interface.
395 </para>
396 <variablelist>
397 <varlistentry>
398 <term>
399 <option>lxc.net</option>
400 </term>
401 <listitem>
402 <para>
403 may be used without a value to clear all previous network options.
404 </para>
405 </listitem>
406 </varlistentry>
407 <varlistentry>
408 <term>
409 <option>lxc.net.[i].type</option>
410 </term>
411 <listitem>
412 <para>
413 specify what kind of network virtualization to be used
414 for the container.
415 Multiple networks can be specified by using an additional index
416 <option>i</option>
417 after all <option>lxc.net.*</option> keys. For example,
418 <option>lxc.net.0.type = veth</option> and
419 <option>lxc.net.1.type = veth</option> specify two different
420 networks of the same type. All keys sharing the same index
421 <option>i</option> will be treated as belonging to the same
422 network. For example, <option>lxc.net.0.link = br0</option>
423 will belong to <option>lxc.net.0.type</option>.
424 Currently, the different virtualization types can be:
425 </para>
426
427 <para>
428 <option>none:</option> will cause the container to share
429 the host's network namespace. This means the host
430 network devices are usable in the container. It also
431 means that if both the container and host have upstart as
432 init, 'halt' in a container (for instance) will shut down the
433 host. Note that unprivileged containers do not work with this
434 setting due to an inability to mount sysfs. An unsafe workaround
435 would be to bind mount the host's sysfs.
436 </para>
437
438 <para>
439 <option>empty:</option> will create only the loopback
440 interface.
441 </para>
442
443 <para>
444 <option>veth:</option> a virtual ethernet pair
445 device is created with one side assigned to the container
446 and the other side attached to a bridge specified by
447 the <option>lxc.net.[i].link</option> option.
448 If the bridge is not specified, then the veth pair device
449 will be created but not attached to any bridge.
450 Otherwise, the bridge has to be created on the system
451 before starting the container.
452 <command>lxc</command> won't handle any
453 configuration outside of the container.
454 By default, <command>lxc</command> chooses a name for the
455 network device belonging to the outside of the
456 container, but if you wish to handle
457 this name yourselves, you can tell <command>lxc</command>
458 to set a specific name with
459 the <option>lxc.net.[i].veth.pair</option> option (except for
460 unprivileged containers where this option is ignored for security
461 reasons).
462
463 Static routes can be added on the host pointing to the container using the
464 <option>lxc.net.[i].veth.ipv4.route</option> and
465 <option>lxc.net.[i].veth.ipv6.route</option> options.
466 Several lines specify several routes.
467 The route is in format x.y.z.t/m, eg. 192.168.1.0/24.
468 </para>
469
470 <para>
471 <option>vlan:</option> a vlan interface is linked with
472 the interface specified by
473 the <option>lxc.net.[i].link</option> and assigned to
474 the container. The vlan identifier is specified with the
475 option <option>lxc.net.[i].vlan.id</option>.
476 </para>
477
478 <para>
479 <option>macvlan:</option> a macvlan interface is linked
480 with the interface specified by
481 the <option>lxc.net.[i].link</option> and assigned to
482 the container.
483 <option>lxc.net.[i].macvlan.mode</option> specifies the
484 mode the macvlan will use to communicate between
485 different macvlan on the same upper device. The accepted
486 modes are <option>private</option>, <option>vepa</option>,
487 <option>bridge</option> and <option>passthru</option>.
488 In <option>private</option> mode, the device never
489 communicates with any other device on the same upper_dev (default).
490 In <option>vepa</option> mode, the new Virtual Ethernet Port
491 Aggregator (VEPA) mode, it assumes that the adjacent
492 bridge returns all frames where both source and
493 destination are local to the macvlan port, i.e. the
494 bridge is set up as a reflective relay. Broadcast
495 frames coming in from the upper_dev get flooded to all
496 macvlan interfaces in VEPA mode, local frames are not
497 delivered locally. In <option>bridge</option> mode, it
498 provides the behavior of a simple bridge between
499 different macvlan interfaces on the same port. Frames
500 from one interface to another one get delivered directly
501 and are not sent out externally. Broadcast frames get
502 flooded to all other bridge ports and to the external
503 interface, but when they come back from a reflective
504 relay, we don't deliver them again. Since we know all
505 the MAC addresses, the macvlan bridge mode does not
506 require learning or STP like the bridge module does. In
507 <option>passthru</option> mode, all frames received by
508 the physical interface are forwarded to the macvlan
509 interface. Only one macvlan interface in <option>passthru</option>
510 mode is possible for one physical interface.
511 </para>
512
513 <para>
514 <option>phys:</option> an already existing interface
515 specified by the <option>lxc.net.[i].link</option> is
516 assigned to the container.
517 </para>
518 </listitem>
519 </varlistentry>
520
521 <varlistentry>
522 <term>
523 <option>lxc.net.[i].flags</option>
524 </term>
525 <listitem>
526 <para>
527 Specify an action to do for the network.
528 </para>
529
530 <para><option>up:</option> activates the interface.
531 </para>
532 </listitem>
533 </varlistentry>
534
535 <varlistentry>
536 <term>
537 <option>lxc.net.[i].link</option>
538 </term>
539 <listitem>
540 <para>
541 Specify the interface to be used for real network traffic.
542 </para>
543 </listitem>
544 </varlistentry>
545
546 <varlistentry>
547 <term>
548 <option>lxc.net.[i].mtu</option>
549 </term>
550 <listitem>
551 <para>
552 Specify the maximum transfer unit for this interface.
553 </para>
554 </listitem>
555 </varlistentry>
556
557 <varlistentry>
558 <term>
559 <option>lxc.net.[i].name</option>
560 </term>
561 <listitem>
562 <para>
563 The interface name is dynamically allocated, but if another name
564 is needed because the configuration files being used by the
565 container use a generic name, eg. eth0, this option will rename
566 the interface in the container.
567 </para>
568 </listitem>
569 </varlistentry>
570
571 <varlistentry>
572 <term>
573 <option>lxc.net.[i].hwaddr</option>
574 </term>
575 <listitem>
576 <para>
577 The interface mac address is dynamically allocated by default to
578 the virtual interface, but in some cases, this is needed to
579 resolve a mac address conflict or to always have the same
580 link-local ipv6 address. Any "x" in address will be replaced by
581 random value, this allows setting hwaddr templates.
582 </para>
583 </listitem>
584 </varlistentry>
585
586 <varlistentry>
587 <term>
588 <option>lxc.net.[i].ipv4.address</option>
589 </term>
590 <listitem>
591 <para>
592 Specify the ipv4 address to assign to the virtualized interface.
593 Several lines specify several ipv4 addresses. The address is in
594 format x.y.z.t/m, eg. 192.168.1.123/24.
595 </para>
596 </listitem>
597 </varlistentry>
598
599 <varlistentry>
600 <term>
601 <option>lxc.net.[i].ipv4.gateway</option>
602 </term>
603 <listitem>
604 <para>
605 Specify the ipv4 address to use as the gateway inside the
606 container. The address is in format x.y.z.t, eg. 192.168.1.123.
607
608 Can also have the special value <option>auto</option>,
609 which means to take the primary address from the bridge
610 interface (as specified by the
611 <option>lxc.net.[i].link</option> option) and use that as
612 the gateway. <option>auto</option> is only available when
613 using the <option>veth</option> and
614 <option>macvlan</option> network types.
615 </para>
616 </listitem>
617 </varlistentry>
618
619 <varlistentry>
620 <term>
621 <option>lxc.net.[i].ipv6.address</option>
622 </term>
623 <listitem>
624 <para>
625 Specify the ipv6 address to assign to the virtualized
626 interface. Several lines specify several ipv6 addresses. The
627 address is in format x::y/m, eg.
628 2003:db8:1:0:214:1234:fe0b:3596/64
629 </para>
630 </listitem>
631 </varlistentry>
632
633 <varlistentry>
634 <term>
635 <option>lxc.net.[i].ipv6.gateway</option>
636 </term>
637 <listitem>
638 <para>
639 Specify the ipv6 address to use as the gateway inside the
640 container. The address is in format x::y, eg. 2003:db8:1:0::1
641
642 Can also have the special value <option>auto</option>,
643 which means to take the primary address from the bridge
644 interface (as specified by the
645 <option>lxc.net.[i].link</option> option) and use that as
646 the gateway. <option>auto</option> is only available when
647 using the <option>veth</option> and
648 <option>macvlan</option> network types.
649 </para>
650 </listitem>
651 </varlistentry>
652
653 <varlistentry>
654 <term>
655 <option>lxc.net.[i].script.up</option>
656 </term>
657 <listitem>
658 <para>
659 Add a configuration option to specify a script to be
660 executed after creating and configuring the network used
661 from the host side.
662 </para>
663
664 <para>
665 In addition to the information available to all hooks. The
666 following information is provided to the script:
667 <itemizedlist>
668 <listitem>
669 <para>
670 LXC_HOOK_TYPE: the hook type. This is either 'up' or 'down'.
671 </para>
672 </listitem>
673
674 <listitem>
675 <para>
676 LXC_HOOK_SECTION: the section type 'net'.
677 </para>
678 </listitem>
679
680 <listitem>
681 <para>
682 LXC_NET_TYPE: the network type. This is one of the valid
683 network types listed here (e.g. 'macvlan', 'veth').
684 </para>
685 </listitem>
686
687 <listitem>
688 <para>
689 LXC_NET_PARENT: the parent device on the host. This is only
690 set for network types 'mavclan', 'veth', 'phys'.
691 </para>
692 </listitem>
693
694 <listitem>
695 <para>
696 LXC_NET_PEER: the name of the peer device on the host. This is
697 only set for 'veth' network types. Note that this information
698 is only available when <option>lxc.hook.version</option> is set
699 to 1.
700 </para>
701 </listitem>
702 </itemizedlist>
703
704 Whether this information is provided in the form of environment
705 variables or as arguments to the script depends on the value of
706 <option>lxc.hook.version</option>. If set to 1 then information is
707 provided in the form of environment variables. If set to 0
708 information is provided as arguments to the script.
709 </para>
710
711 <para>
712 Standard output from the script is logged at debug level.
713 Standard error is not logged, but can be captured by the
714 hook redirecting its standard error to standard output.
715 </para>
716 </listitem>
717 </varlistentry>
718
719 <varlistentry>
720 <term>
721 <option>lxc.net.[i].script.down</option>
722 </term>
723 <listitem>
724 <para>
725 Add a configuration option to specify a script to be
726 executed before destroying the network used from the
727 host side.
728 </para>
729
730 <para>
731 In addition to the information available to all hooks. The
732 following information is provided to the script:
733 <itemizedlist>
734 <listitem>
735 <para>
736 LXC_HOOK_TYPE: the hook type. This is either 'up' or 'down'.
737 </para>
738 </listitem>
739
740 <listitem>
741 <para>
742 LXC_HOOK_SECTION: the section type 'net'.
743 </para>
744 </listitem>
745
746 <listitem>
747 <para>
748 LXC_NET_TYPE: the network type. This is one of the valid
749 network types listed here (e.g. 'macvlan', 'veth').
750 </para>
751 </listitem>
752
753 <listitem>
754 <para>
755 LXC_NET_PARENT: the parent device on the host. This is only
756 set for network types 'mavclan', 'veth', 'phys'.
757 </para>
758 </listitem>
759
760 <listitem>
761 <para>
762 LXC_NET_PEER: the name of the peer device on the host. This is
763 only set for 'veth' network types. Note that this information
764 is only available when <option>lxc.hook.version</option> is set
765 to 1.
766 </para>
767 </listitem>
768 </itemizedlist>
769
770 Whether this information is provided in the form of environment
771 variables or as arguments to the script depends on the value of
772 <option>lxc.hook.version</option>. If set to 1 then information is
773 provided in the form of environment variables. If set to 0
774 information is provided as arguments to the script.
775 </para>
776
777 <para>
778 Standard output from the script is logged at debug level.
779 Standard error is not logged, but can be captured by the
780 hook redirecting its standard error to standard output.
781 </para>
782 </listitem>
783 </varlistentry>
784 </variablelist>
785 </refsect2>
786
787 <refsect2>
788 <title>New pseudo tty instance (devpts)</title>
789 <para>
790 For stricter isolation the container can have its own private
791 instance of the pseudo tty.
792 </para>
793 <variablelist>
794 <varlistentry>
795 <term>
796 <option>lxc.pty.max</option>
797 </term>
798 <listitem>
799 <para>
800 If set, the container will have a new pseudo tty
801 instance, making this private to it. The value specifies
802 the maximum number of pseudo ttys allowed for a pts
803 instance (this limitation is not implemented yet).
804 </para>
805 </listitem>
806 </varlistentry>
807 </variablelist>
808 </refsect2>
809
810 <refsect2>
811 <title>Container system console</title>
812 <para>
813 If the container is configured with a root filesystem and the
814 inittab file is setup to use the console, you may want to specify
815 where the output of this console goes.
816 </para>
817 <variablelist>
818
819 <varlistentry>
820 <term>
821 <option>lxc.console.buffer.size</option>
822 </term>
823 <listitem>
824 <para>
825 Setting this option instructs liblxc to allocate an in-memory
826 ringbuffer. The container's console output will be written to the
827 ringbuffer. Note that ringbuffer must be at least as big as a
828 standard page size. When passed a value smaller than a single page
829 size liblxc will allocate a ringbuffer of a single page size. A page
830 size is usually 4KB.
831
832 The keyword 'auto' will cause liblxc to allocate a ringbuffer of
833 128KB.
834
835 When manually specifying a size for the ringbuffer the value should
836 be a power of 2 when converted to bytes. Valid size prefixes are
837 'KB', 'MB', 'GB'. (Note that all conversions are based on multiples
838 of 1024. That means 'KB' == 'KiB', 'MB' == 'MiB', 'GB' == 'GiB'.
839 Additionally, the case of the suffix is ignored, i.e. 'kB', 'KB' and
840 'Kb' are treated equally.)
841 </para>
842 </listitem>
843 </varlistentry>
844
845 <varlistentry>
846 <term>
847 <option>lxc.console.size</option>
848 </term>
849 <listitem>
850 <para>
851 Setting this option instructs liblxc to place a limit on the size of
852 the console log file specified in
853 <option>lxc.console.logfile</option>. Note that size of the log file
854 must be at least as big as a standard page size. When passed a value
855 smaller than a single page size liblxc will set the size of log file
856 to a single page size. A page size is usually 4KB.
857
858 The keyword 'auto' will cause liblxc to place a limit of 128KB on
859 the log file.
860
861 When manually specifying a size for the log file the value should
862 be a power of 2 when converted to bytes. Valid size prefixes are
863 'KB', 'MB', 'GB'. (Note that all conversions are based on multiples
864 of 1024. That means 'KB' == 'KiB', 'MB' == 'MiB', 'GB' == 'GiB'.
865 Additionally, the case of the suffix is ignored, i.e. 'kB', 'KB' and
866 'Kb' are treated equally.)
867
868 If users want to mirror the console ringbuffer on disk they should set
869 <option>lxc.console.size</option> equal to
870 <option>lxc.console.buffer.size</option>.
871 </para>
872 </listitem>
873 </varlistentry>
874
875 <varlistentry>
876 <term>
877 <option>lxc.console.logfile</option>
878 </term>
879 <listitem>
880 <para>
881 Specify a path to a file where the console output will be written.
882 Note that in contrast to the on-disk ringbuffer logfile this file
883 will keep growing potentially filling up the users disks if not
884 rotated and deleted. This problem can also be avoided by using the
885 in-memory ringbuffer options
886 <option>lxc.console.buffer.size</option> and
887 <option>lxc.console.buffer.logfile</option>.
888 </para>
889 </listitem>
890 </varlistentry>
891
892 <varlistentry>
893 <term>
894 <option>lxc.console.rotate</option>
895 </term>
896 <listitem>
897 <para>
898 Whether to rotate the console logfile specified in
899 <option>lxc.console.logfile</option>. Users can send an API
900 request to rotate the logfile. Note that the old logfile will have
901 the same name as the original with the suffix ".1" appended.
902
903 Users wishing to prevent the console log file from filling the
904 disk should rotate the logfile and delete it if unneeded. This
905 problem can also be avoided by using the in-memory ringbuffer
906 options <option>lxc.console.buffer.size</option> and
907 <option>lxc.console.buffer.logfile</option>.
908 </para>
909 </listitem>
910 </varlistentry>
911
912 <varlistentry>
913 <term>
914 <option>lxc.console.path</option>
915 </term>
916 <listitem>
917 <para>
918 Specify a path to a device to which the console will be
919 attached. The keyword 'none' will simply disable the
920 console. Note, when specifying 'none' and creating a device node
921 for the console in the container at /dev/console or bind-mounting
922 the hosts's /dev/console into the container at /dev/console the
923 container will have direct access to the hosts's /dev/console.
924 This is dangerous when the container has write access to the
925 device and should thus be used with caution.
926 </para>
927 </listitem>
928 </varlistentry>
929 </variablelist>
930 </refsect2>
931
932 <refsect2>
933 <title>Console through the ttys</title>
934 <para>
935 This option is useful if the container is configured with a root
936 filesystem and the inittab file is setup to launch a getty on the
937 ttys. The option specifies the number of ttys to be available for
938 the container. The number of gettys in the inittab file of the
939 container should not be greater than the number of ttys specified
940 in this option, otherwise the excess getty sessions will die and
941 respawn indefinitely giving annoying messages on the console or in
942 <filename>/var/log/messages</filename>.
943 </para>
944 <variablelist>
945 <varlistentry>
946 <term>
947 <option>lxc.tty.max</option>
948 </term>
949 <listitem>
950 <para>
951 Specify the number of tty to make available to the
952 container.
953 </para>
954 </listitem>
955 </varlistentry>
956 </variablelist>
957 </refsect2>
958
959 <refsect2>
960 <title>Console devices location</title>
961 <para>
962 LXC consoles are provided through Unix98 PTYs created on the
963 host and bind-mounted over the expected devices in the container.
964 By default, they are bind-mounted over <filename>/dev/console</filename>
965 and <filename>/dev/ttyN</filename>. This can prevent package upgrades
966 in the guest. Therefore you can specify a directory location (under
967 <filename>/dev</filename> under which LXC will create the files and
968 bind-mount over them. These will then be symbolically linked to
969 <filename>/dev/console</filename> and <filename>/dev/ttyN</filename>.
970 A package upgrade can then succeed as it is able to remove and replace
971 the symbolic links.
972 </para>
973 <variablelist>
974 <varlistentry>
975 <term>
976 <option>lxc.tty.dir</option>
977 </term>
978 <listitem>
979 <para>
980 Specify a directory under <filename>/dev</filename>
981 under which to create the container console devices. Note that LXC
982 will move any bind-mounts or device nodes for /dev/console into
983 this directory.
984 </para>
985 </listitem>
986 </varlistentry>
987 </variablelist>
988 </refsect2>
989
990 <refsect2>
991 <title>/dev directory</title>
992 <para>
993 By default, lxc creates a few symbolic links (fd,stdin,stdout,stderr)
994 in the container's <filename>/dev</filename> directory but does not
995 automatically create device node entries. This allows the container's
996 <filename>/dev</filename> to be set up as needed in the container
997 rootfs. If lxc.autodev is set to 1, then after mounting the container's
998 rootfs LXC will mount a fresh tmpfs under <filename>/dev</filename>
999 (limited to 500k) and fill in a minimal set of initial devices.
1000 This is generally required when starting a container containing
1001 a "systemd" based "init" but may be optional at other times. Additional
1002 devices in the containers /dev directory may be created through the
1003 use of the <option>lxc.hook.autodev</option> hook.
1004 </para>
1005 <variablelist>
1006 <varlistentry>
1007 <term>
1008 <option>lxc.autodev</option>
1009 </term>
1010 <listitem>
1011 <para>
1012 Set this to 0 to stop LXC from mounting and populating a minimal
1013 <filename>/dev</filename> when starting the container.
1014 </para>
1015 </listitem>
1016 </varlistentry>
1017 </variablelist>
1018 </refsect2>
1019
1020 <refsect2>
1021 <title>Mount points</title>
1022 <para>
1023 The mount points section specifies the different places to be
1024 mounted. These mount points will be private to the container
1025 and won't be visible by the processes running outside of the
1026 container. This is useful to mount /etc, /var or /home for
1027 examples.
1028 </para>
1029 <para>
1030 NOTE - LXC will generally ensure that mount targets and relative
1031 bind-mount sources are properly confined under the container
1032 root, to avoid attacks involving over-mounting host directories
1033 and files. (Symbolic links in absolute mount sources are ignored)
1034 However, if the container configuration first mounts a directory which
1035 is under the control of the container user, such as /home/joe, into
1036 the container at some <filename>path</filename>, and then mounts
1037 under <filename>path</filename>, then a TOCTTOU attack would be
1038 possible where the container user modifies a symbolic link under
1039 his home directory at just the right time.
1040 </para>
1041 <variablelist>
1042 <varlistentry>
1043 <term>
1044 <option>lxc.mount.fstab</option>
1045 </term>
1046 <listitem>
1047 <para>
1048 specify a file location in
1049 the <filename>fstab</filename> format, containing the
1050 mount information. The mount target location can and in
1051 most cases should be a relative path, which will become
1052 relative to the mounted container root. For instance,
1053 </para>
1054 <programlisting>
1055 proc proc proc nodev,noexec,nosuid 0 0
1056 </programlisting>
1057 <para>
1058 Will mount a proc filesystem under the container's /proc,
1059 regardless of where the root filesystem comes from. This
1060 is resilient to block device backed filesystems as well as
1061 container cloning.
1062 </para>
1063 <para>
1064 Note that when mounting a filesystem from an
1065 image file or block device the third field (fs_vfstype)
1066 cannot be auto as with
1067 <citerefentry>
1068 <refentrytitle>mount</refentrytitle>
1069 <manvolnum>8</manvolnum>
1070 </citerefentry>
1071 but must be explicitly specified.
1072 </para>
1073 </listitem>
1074 </varlistentry>
1075
1076 <varlistentry>
1077 <term>
1078 <option>lxc.mount.entry</option>
1079 </term>
1080 <listitem>
1081 <para>
1082 Specify a mount point corresponding to a line in the
1083 fstab format.
1084
1085 Moreover lxc supports mount propagation, such as rslave or
1086 rprivate, and adds three additional mount options.
1087 <option>optional</option> don't fail if mount does not work.
1088 <option>create=dir</option> or <option>create=file</option>
1089 to create dir (or file) when the point will be mounted.
1090 <option>relative</option> source path is taken to be relative to
1091 the mounted container root. For instance,
1092 </para>
1093 <screen>
1094 dev/null proc/kcore none bind,relative 0 0
1095 </screen>
1096 <para>
1097 Will expand dev/null to ${<option>LXC_ROOTFS_MOUNT</option>}/dev/null,
1098 and mount it to proc/kcore inside the container.
1099 </para>
1100 </listitem>
1101 </varlistentry>
1102
1103 <varlistentry>
1104 <term>
1105 <option>lxc.mount.auto</option>
1106 </term>
1107 <listitem>
1108 <para>
1109 specify which standard kernel file systems should be
1110 automatically mounted. This may dramatically simplify
1111 the configuration. The file systems are:
1112 </para>
1113 <itemizedlist>
1114 <listitem>
1115 <para>
1116 <option>proc:mixed</option> (or <option>proc</option>):
1117 mount <filename>/proc</filename> as read-write, but
1118 remount <filename>/proc/sys</filename> and
1119 <filename>/proc/sysrq-trigger</filename> read-only
1120 for security / container isolation purposes.
1121 </para>
1122 </listitem>
1123 <listitem>
1124 <para>
1125 <option>proc:rw</option>: mount
1126 <filename>/proc</filename> as read-write
1127 </para>
1128 </listitem>
1129 <listitem>
1130 <para>
1131 <option>sys:mixed</option> (or <option>sys</option>):
1132 mount <filename>/sys</filename> as read-only but with
1133 /sys/devices/virtual/net writable.
1134 </para>
1135 </listitem>
1136 <listitem>
1137 <para>
1138 <option>sys:ro</option>:
1139 mount <filename>/sys</filename> as read-only
1140 for security / container isolation purposes.
1141 </para>
1142 </listitem>
1143 <listitem>
1144 <para>
1145 <option>sys:rw</option>: mount
1146 <filename>/sys</filename> as read-write
1147 </para>
1148 </listitem>
1149
1150 <listitem>
1151 <para>
1152 <option>cgroup:mixed</option>:
1153 Mount a tmpfs to <filename>/sys/fs/cgroup</filename>,
1154 create directories for all hierarchies to which the container
1155 is added, create subdirectories in those hierarchies with the
1156 name of the cgroup, and bind-mount the container's own cgroup
1157 into that directory. The container will be able to write to
1158 its own cgroup directory, but not the parents, since they will
1159 be remounted read-only.
1160 </para>
1161 </listitem>
1162
1163 <listitem>
1164 <para>
1165 <option>cgroup:mixed:force</option>:
1166 The <option>force</option> option will cause LXC to perform
1167 the cgroup mounts for the container under all circumstances.
1168 Otherwise it is similar to <option>cgroup:mixed</option>.
1169 This is mainly useful when the cgroup namespaces are enabled
1170 where LXC will normally leave mounting cgroups to the init
1171 binary of the container since it is perfectly safe to do so.
1172 </para>
1173 </listitem>
1174
1175 <listitem>
1176 <para>
1177 <option>cgroup:ro</option>:
1178 similar to <option>cgroup:mixed</option>, but everything will
1179 be mounted read-only.
1180 </para>
1181 </listitem>
1182
1183 <listitem>
1184 <para>
1185 <option>cgroup:ro:force</option>:
1186 The <option>force</option> option will cause LXC to perform
1187 the cgroup mounts for the container under all circumstances.
1188 Otherwise it is similar to <option>cgroup:ro</option>.
1189 This is mainly useful when the cgroup namespaces are enabled
1190 where LXC will normally leave mounting cgroups to the init
1191 binary of the container since it is perfectly safe to do so.
1192 </para>
1193 </listitem>
1194
1195 <listitem>
1196 <para>
1197 <option>cgroup:rw</option>: similar to
1198 <option>cgroup:mixed</option>, but everything will be mounted
1199 read-write. Note that the paths leading up to the container's
1200 own cgroup will be writable, but will not be a cgroup
1201 filesystem but just part of the tmpfs of
1202 <filename>/sys/fs/cgroup</filename>
1203 </para>
1204 </listitem>
1205
1206 <listitem>
1207 <para>
1208 <option>cgroup:rw:force</option>:
1209 The <option>force</option> option will cause LXC to perform
1210 the cgroup mounts for the container under all circumstances.
1211 Otherwise it is similar to <option>cgroup:rw</option>.
1212 This is mainly useful when the cgroup namespaces are enabled
1213 where LXC will normally leave mounting cgroups to the init
1214 binary of the container since it is perfectly safe to do so.
1215 </para>
1216 </listitem>
1217
1218 <listitem>
1219 <para>
1220 <option>cgroup</option> (without specifier):
1221 defaults to <option>cgroup:rw</option> if the
1222 container retains the CAP_SYS_ADMIN capability,
1223 <option>cgroup:mixed</option> otherwise.
1224 </para>
1225 </listitem>
1226
1227 <listitem>
1228 <para>
1229 <option>cgroup-full:mixed</option>:
1230 mount a tmpfs to <filename>/sys/fs/cgroup</filename>,
1231 create directories for all hierarchies to which
1232 the container is added, bind-mount the hierarchies
1233 from the host to the container and make everything
1234 read-only except the container's own cgroup. Note
1235 that compared to <option>cgroup</option>, where
1236 all paths leading up to the container's own cgroup
1237 are just simple directories in the underlying
1238 tmpfs, here
1239 <filename>/sys/fs/cgroup/$hierarchy</filename>
1240 will contain the host's full cgroup hierarchy,
1241 albeit read-only outside the container's own cgroup.
1242 This may leak quite a bit of information into the
1243 container.
1244 </para>
1245 </listitem>
1246
1247 <listitem>
1248 <para>
1249 <option>cgroup-full:mixed:force</option>:
1250 The <option>force</option> option will cause LXC to perform
1251 the cgroup mounts for the container under all circumstances.
1252 Otherwise it is similar to <option>cgroup-full:mixed</option>.
1253 This is mainly useful when the cgroup namespaces are enabled
1254 where LXC will normally leave mounting cgroups to the init
1255 binary of the container since it is perfectly safe to do so.
1256 </para>
1257 </listitem>
1258
1259 <listitem>
1260 <para>
1261 <option>cgroup-full:ro</option>: similar to
1262 <option>cgroup-full:mixed</option>, but everything
1263 will be mounted read-only.
1264 </para>
1265 </listitem>
1266
1267 <listitem>
1268 <para>
1269 <option>cgroup-full:ro:force</option>:
1270 The <option>force</option> option will cause LXC to perform
1271 the cgroup mounts for the container under all circumstances.
1272 Otherwise it is similar to <option>cgroup-full:ro</option>.
1273 This is mainly useful when the cgroup namespaces are enabled
1274 where LXC will normally leave mounting cgroups to the init
1275 binary of the container since it is perfectly safe to do so.
1276 </para>
1277 </listitem>
1278
1279 <listitem>
1280 <para>
1281 <option>cgroup-full:rw</option>: similar to
1282 <option>cgroup-full:mixed</option>, but everything
1283 will be mounted read-write. Note that in this case,
1284 the container may escape its own cgroup. (Note also
1285 that if the container has CAP_SYS_ADMIN support
1286 and can mount the cgroup filesystem itself, it may
1287 do so anyway.)
1288 </para>
1289 </listitem>
1290
1291 <listitem>
1292 <para>
1293 <option>cgroup-full:rw:force</option>:
1294 The <option>force</option> option will cause LXC to perform
1295 the cgroup mounts for the container under all circumstances.
1296 Otherwise it is similar to <option>cgroup-full:rw</option>.
1297 This is mainly useful when the cgroup namespaces are enabled
1298 where LXC will normally leave mounting cgroups to the init
1299 binary of the container since it is perfectly safe to do so.
1300 </para>
1301 </listitem>
1302
1303 <listitem>
1304 <para>
1305 <option>cgroup-full</option> (without specifier):
1306 defaults to <option>cgroup-full:rw</option> if the
1307 container retains the CAP_SYS_ADMIN capability,
1308 <option>cgroup-full:mixed</option> otherwise.
1309 </para>
1310 </listitem>
1311
1312 </itemizedlist>
1313 <para>
1314 If cgroup namespaces are enabled, then any <option>cgroup</option>
1315 auto-mounting request will be ignored, since the container can
1316 mount the filesystems itself, and automounting can confuse the
1317 container init.
1318 </para>
1319 <para>
1320 Note that if automatic mounting of the cgroup filesystem
1321 is enabled, the tmpfs under
1322 <filename>/sys/fs/cgroup</filename> will always be
1323 mounted read-write (but for the <option>:mixed</option>
1324 and <option>:ro</option> cases, the individual
1325 hierarchies,
1326 <filename>/sys/fs/cgroup/$hierarchy</filename>, will be
1327 read-only). This is in order to work around a quirk in
1328 Ubuntu's
1329 <citerefentry>
1330 <refentrytitle>mountall</refentrytitle>
1331 <manvolnum>8</manvolnum>
1332 </citerefentry>
1333 command that will cause containers to wait for user
1334 input at boot if
1335 <filename>/sys/fs/cgroup</filename> is mounted read-only
1336 and the container can't remount it read-write due to a
1337 lack of CAP_SYS_ADMIN.
1338 </para>
1339 <para>
1340 Examples:
1341 </para>
1342 <programlisting>
1343 lxc.mount.auto = proc sys cgroup
1344 lxc.mount.auto = proc:rw sys:rw cgroup-full:rw
1345 </programlisting>
1346 </listitem>
1347 </varlistentry>
1348
1349 </variablelist>
1350 </refsect2>
1351
1352 <refsect2>
1353 <title>Root file system</title>
1354 <para>
1355 The root file system of the container can be different than that
1356 of the host system.
1357 </para>
1358 <variablelist>
1359 <varlistentry>
1360 <term>
1361 <option>lxc.rootfs.path</option>
1362 </term>
1363 <listitem>
1364 <para>
1365 specify the root file system for the container. It can
1366 be an image file, a directory or a block device. If not
1367 specified, the container shares its root file system
1368 with the host.
1369 </para>
1370 <para>
1371 For directory or simple block-device backed containers,
1372 a pathname can be used. If the rootfs is backed by a nbd
1373 device, then <filename>nbd:file:1</filename> specifies that
1374 <filename>file</filename> should be attached to a nbd device,
1375 and partition 1 should be mounted as the rootfs.
1376 <filename>nbd:file</filename> specifies that the nbd device
1377 itself should be mounted. <filename>overlayfs:/lower:/upper</filename>
1378 specifies that the rootfs should be an overlay with <filename>/upper</filename>
1379 being mounted read-write over a read-only mount of <filename>/lower</filename>.
1380 For <filename>overlay</filename> multiple <filename>/lower</filename>
1381 directories can be specified. <filename>loop:/file</filename> tells lxc to attach
1382 <filename>/file</filename> to a loop device and mount the loop device.
1383 </para>
1384 </listitem>
1385 </varlistentry>
1386
1387 <varlistentry>
1388 <term>
1389 <option>lxc.rootfs.mount</option>
1390 </term>
1391 <listitem>
1392 <para>
1393 where to recursively bind <option>lxc.rootfs.path</option>
1394 before pivoting. This is to ensure success of the
1395 <citerefentry>
1396 <refentrytitle><command>pivot_root</command></refentrytitle>
1397 <manvolnum>8</manvolnum>
1398 </citerefentry>
1399 syscall. Any directory suffices, the default should
1400 generally work.
1401 </para>
1402 </listitem>
1403 </varlistentry>
1404
1405 <varlistentry>
1406 <term>
1407 <option>lxc.rootfs.options</option>
1408 </term>
1409 <listitem>
1410 <para>
1411 extra mount options to use when mounting the rootfs.
1412 </para>
1413 </listitem>
1414 </varlistentry>
1415
1416 <varlistentry>
1417 <term>
1418 <option>lxc.rootfs.managed</option>
1419 </term>
1420 <listitem>
1421 <para>
1422 Set this to 0 to indicate that LXC is not managing the
1423 container storage, then LXC will not modify the
1424 container storage. The default is 1.
1425 </para>
1426 </listitem>
1427 </varlistentry>
1428
1429 </variablelist>
1430 </refsect2>
1431
1432 <refsect2>
1433 <title>Control group</title>
1434 <para>
1435 The control group section contains the configuration for the
1436 different subsystem. <command>lxc</command> does not check the
1437 correctness of the subsystem name. This has the disadvantage
1438 of not detecting configuration errors until the container is
1439 started, but has the advantage of permitting any future
1440 subsystem.
1441 </para>
1442 <variablelist>
1443 <varlistentry>
1444 <term>
1445 <option>lxc.cgroup.[controller name]</option>
1446 </term>
1447 <listitem>
1448 <para>
1449 Specify the control group value to be set on a legacy cgroup
1450 hierarchy. The controller name is the literal name of the control
1451 group. The permitted names and the syntax of their values is not
1452 dictated by LXC, instead it depends on the features of the Linux
1453 kernel running at the time the container is started, eg.
1454 <option>lxc.cgroup.cpuset.cpus</option>
1455 </para>
1456 </listitem>
1457 </varlistentry>
1458 <varlistentry>
1459 <term>
1460 <option>lxc.cgroup2.[controller name]</option>
1461 </term>
1462 <listitem>
1463 <para>
1464 Specify the control group value to be set on the unified cgroup
1465 hierarchy. The controller name is the literal name of the control
1466 group. The permitted names and the syntax of their values is not
1467 dictated by LXC, instead it depends on the features of the Linux
1468 kernel running at the time the container is started, eg.
1469 <option>lxc.cgroup2.memory.high</option>
1470 </para>
1471 </listitem>
1472 </varlistentry>
1473 <varlistentry>
1474 <term>
1475 <option>lxc.cgroup.dir</option>
1476 </term>
1477 <listitem>
1478 <para>
1479 specify a directory or path in which the container's cgroup will
1480 be created. For example, setting
1481 <option>lxc.cgroup.dir = my-cgroup/first</option> for a container
1482 named "c1" will create the container's cgroup as a sub-cgroup of
1483 "my-cgroup". For example, if the user's current cgroup "my-user"
1484 is located in the root cgroup of the cpuset controller in a
1485 cgroup v1 hierarchy this would create the cgroup
1486 "/sys/fs/cgroup/cpuset/my-user/my-cgroup/first/c1" for the
1487 container. Any missing cgroups will be created by LXC. This
1488 presupposes that the user has write access to its current cgroup.
1489 </para>
1490 </listitem>
1491 </varlistentry>
1492 <varlistentry>
1493 <term>
1494 <option>lxc.cgroup.relative</option>
1495 </term>
1496 <listitem>
1497 <para>
1498 Set this to 1 to instruct LXC to never escape to the
1499 root cgroup. This makes it easy for users to adhere to
1500 restrictions enforced by cgroup2 and
1501 systemd. Specifically, this makes it possible to run LXC
1502 containers as systemd services.
1503 </para>
1504 </listitem>
1505 </varlistentry>
1506 </variablelist>
1507 </refsect2>
1508
1509 <refsect2>
1510 <title>Capabilities</title>
1511 <para>
1512 The capabilities can be dropped in the container if this one
1513 is run as root.
1514 </para>
1515 <variablelist>
1516 <varlistentry>
1517 <term>
1518 <option>lxc.cap.drop</option>
1519 </term>
1520 <listitem>
1521 <para>
1522 Specify the capability to be dropped in the container. A
1523 single line defining several capabilities with a space
1524 separation is allowed. The format is the lower case of
1525 the capability definition without the "CAP_" prefix,
1526 eg. CAP_SYS_MODULE should be specified as
1527 sys_module. See
1528 <citerefentry>
1529 <refentrytitle><command>capabilities</command></refentrytitle>
1530 <manvolnum>7</manvolnum>
1531 </citerefentry>.
1532 If used with no value, lxc will clear any drop capabilities
1533 specified up to this point.
1534 </para>
1535 </listitem>
1536 </varlistentry>
1537 <varlistentry>
1538 <term>
1539 <option>lxc.cap.keep</option>
1540 </term>
1541 <listitem>
1542 <para>
1543 Specify the capability to be kept in the container. All other
1544 capabilities will be dropped. When a special value of "none" is
1545 encountered, lxc will clear any keep capabilities specified up
1546 to this point. A value of "none" alone can be used to drop all
1547 capabilities.
1548 </para>
1549 </listitem>
1550 </varlistentry>
1551 </variablelist>
1552 </refsect2>
1553
1554 <refsect2>
1555 <title>Namespaces</title>
1556 <para>
1557 A namespace can be cloned (<option>lxc.namespace.clone</option>),
1558 kept (<option>lxc.namespace.keep</option>) or shared
1559 (<option>lxc.namespace.share.[namespace identifier]</option>).
1560 </para>
1561 <variablelist>
1562 <varlistentry>
1563 <term>
1564 <option>lxc.namespace.clone</option>
1565 </term>
1566 <listitem>
1567 <para>
1568 Specify namespaces which the container is supposed to be created
1569 with. The namespaces to create are specified as a space separated
1570 list. Each namespace must correspond to one of the standard
1571 namespace identifiers as seen in the
1572 <filename>/proc/PID/ns</filename> directory.
1573 When <option>lxc.namespace.clone</option> is not explicitly set all
1574 namespaces supported by the kernel and the current configuration
1575 will be used.
1576 </para>
1577
1578 <para>
1579 To create a new mount, net and ipc namespace set
1580 <option>lxc.namespace.clone=mount net ipc</option>.
1581 </para>
1582 </listitem>
1583 </varlistentry>
1584
1585 <varlistentry>
1586 <term>
1587 <option>lxc.namespace.keep</option>
1588 </term>
1589 <listitem>
1590 <para>
1591 Specify namespaces which the container is supposed to inherit from
1592 the process that created it. The namespaces to keep are specified as
1593 a space separated list. Each namespace must correspond to one of the
1594 standard namespace identifiers as seen in the
1595 <filename>/proc/PID/ns</filename> directory.
1596 The <option>lxc.namespace.keep</option> is a
1597 blacklist option, i.e. it is useful when enforcing that containers
1598 must keep a specific set of namespaces.
1599 </para>
1600
1601 <para>
1602 To keep the network, user and ipc namespace set
1603 <option>lxc.namespace.keep=user net ipc</option>.
1604 </para>
1605
1606 <para>
1607 Note that sharing pid namespaces will likely not work with most init
1608 systems.
1609 </para>
1610
1611 <para>
1612 Note that if the container requests a new user namespace and the
1613 container wants to inherit the network namespace it needs to inherit
1614 the user namespace as well.
1615 </para>
1616 </listitem>
1617 </varlistentry>
1618
1619 <varlistentry>
1620 <term>
1621 <option>lxc.namespace.share.[namespace identifier]</option>
1622 </term>
1623 <listitem>
1624 <para>
1625 Specify a namespace to inherit from another container or process.
1626 The <option>[namespace identifier]</option> suffix needs to be
1627 replaced with one of the namespaces that appear in the
1628 <filename>/proc/PID/ns</filename> directory.
1629 </para>
1630
1631 <para>
1632 To inherit the namespace from another process set the
1633 <option>lxc.namespace.share.[namespace identifier]</option> to the PID of
1634 the process, e.g. <option>lxc.namespace.share.net=42</option>.
1635 </para>
1636
1637 <para>
1638 To inherit the namespace from another container set the
1639 <option>lxc.namespace.share.[namespace identifier]</option> to the name of
1640 the container, e.g. <option>lxc.namespace.share.pid=c3</option>.
1641 </para>
1642
1643 <para>
1644 To inherit the namespace from another container located in a
1645 different path than the standard liblxc path set the
1646 <option>lxc.namespace.share.[namespace identifier]</option> to the full
1647 path to the container, e.g.
1648 <option>lxc.namespace.share.user=/opt/c3</option>.
1649 </para>
1650
1651 <para>
1652 In order to inherit namespaces the caller needs to have sufficient
1653 privilege over the process or container.
1654 </para>
1655
1656 <para>
1657 Note that sharing pid namespaces between system containers will
1658 likely not work with most init systems.
1659 </para>
1660
1661 <para>
1662 Note that if two processes are in different user namespaces and one
1663 process wants to inherit the other's network namespace it usually
1664 needs to inherit the user namespace as well.
1665 </para>
1666 </listitem>
1667 </varlistentry>
1668 </variablelist>
1669 </refsect2>
1670
1671 <refsect2>
1672 <title>Resource limits</title>
1673 <para>
1674 The soft and hard resource limits for the container can be changed.
1675 Unprivileged containers can only lower them. Resources which are not
1676 explicitly specified will be inherited.
1677 </para>
1678 <variablelist>
1679 <varlistentry>
1680 <term>
1681 <option>lxc.prlimit.[limit name]</option>
1682 </term>
1683 <listitem>
1684 <para>
1685 Specify the resource limit to be set. A limit is specified as two
1686 colon separated values which are either numeric or the word
1687 'unlimited'. A single value can be used as a shortcut to set both
1688 soft and hard limit to the same value. The permitted names the
1689 "RLIMIT_" resource names in lowercase without the "RLIMIT_"
1690 prefix, eg. RLIMIT_NOFILE should be specified as "nofile". See
1691 <citerefentry>
1692 <refentrytitle><command>setrlimit</command></refentrytitle>
1693 <manvolnum>2</manvolnum>
1694 </citerefentry>.
1695 If used with no value, lxc will clear the resource limit
1696 specified up to this point. A resource with no explicitly
1697 configured limitation will be inherited from the process starting
1698 up the container.
1699 </para>
1700 </listitem>
1701 </varlistentry>
1702 </variablelist>
1703 </refsect2>
1704
1705 <refsect2>
1706 <title>Sysctl</title>
1707 <para>
1708 Configure kernel parameters for the container.
1709 </para>
1710 <variablelist>
1711 <varlistentry>
1712 <term>
1713 <option>lxc.sysctl.[kernel parameters name]</option>
1714 </term>
1715 <listitem>
1716 <para>
1717 Specify the kernel parameters to be set. The parameters available
1718 are those listed under /proc/sys/.
1719 Note that not all sysctls are namespaced. Changing Non-namespaced
1720 sysctls will cause the system-wide setting to be modified.
1721 <citerefentry>
1722 <refentrytitle><command>sysctl</command></refentrytitle>
1723 <manvolnum>8</manvolnum>
1724 </citerefentry>.
1725 If used with no value, lxc will clear the parameters specified up
1726 to this point.
1727 </para>
1728 </listitem>
1729 </varlistentry>
1730 </variablelist>
1731 </refsect2>
1732
1733 <refsect2>
1734 <title>Apparmor profile</title>
1735 <para>
1736 If lxc was compiled and installed with apparmor support, and the host
1737 system has apparmor enabled, then the apparmor profile under which the
1738 container should be run can be specified in the container
1739 configuration. The default is <command>lxc-container-default-cgns</command>
1740 if the host kernel is cgroup namespace aware, or
1741 <command>lxc-container-default</command> otherwise.
1742 </para>
1743 <variablelist>
1744 <varlistentry>
1745 <term>
1746 <option>lxc.apparmor.profile</option>
1747 </term>
1748 <listitem>
1749 <para>
1750 Specify the apparmor profile under which the container should
1751 be run. To specify that the container should be unconfined,
1752 use
1753 </para>
1754 <programlisting>lxc.apparmor.profile = unconfined</programlisting>
1755 <para>
1756 If the apparmor profile should remain unchanged (i.e. if you
1757 are nesting containers and are already confined), then use
1758 </para>
1759 <programlisting>lxc.apparmor.profile = unchanged</programlisting>
1760 <para>
1761 If you instruct LXC to generate the apparmor profile,
1762 then use
1763 </para>
1764 <programlisting>lxc.apparmor.profile = generated</programlisting>
1765 </listitem>
1766 </varlistentry>
1767 <varlistentry>
1768 <term>
1769 <option>lxc.apparmor.allow_incomplete</option>
1770 </term>
1771 <listitem>
1772 <para>
1773 Apparmor profiles are pathname based. Therefore many file
1774 restrictions require mount restrictions to be effective against
1775 a determined attacker. However, these mount restrictions are not
1776 yet implemented in the upstream kernel. Without the mount
1777 restrictions, the apparmor profiles still protect against accidental
1778 damager.
1779 </para>
1780 <para>
1781 If this flag is 0 (default), then the container will not be
1782 started if the kernel lacks the apparmor mount features, so that a
1783 regression after a kernel upgrade will be detected. To start the
1784 container under partial apparmor protection, set this flag to 1.
1785 </para>
1786 </listitem>
1787 </varlistentry>
1788
1789 <varlistentry>
1790 <term>
1791 <option>lxc.apparmor.allow_nesting</option>
1792 </term>
1793 <listitem>
1794 <para>
1795 If set this to 1, causes the following changes. When
1796 generated apparmor profiles are used, they will contain
1797 the necessary changes to allow creating a nested
1798 container. In addition to the usual mount points,
1799 <filename>/dev/.lxc/proc</filename>
1800 and <filename>/dev/.lxc/sys</filename> will contain
1801 procfs and sysfs mount points without the lxcfs
1802 overlays, which, if generated apparmor profiles are
1803 being used, will not be read/writable directly.
1804 </para>
1805 </listitem>
1806 </varlistentry>
1807
1808 <varlistentry>
1809 <term>
1810 <option>lxc.apparmor.raw</option>
1811 </term>
1812 <listitem>
1813 <para>
1814 A list of raw AppArmor profile lines to append to the
1815 profile. Only valid when using generated profiles.
1816 </para>
1817 </listitem>
1818 </varlistentry>
1819
1820 </variablelist>
1821 </refsect2>
1822
1823 <refsect2>
1824 <title>SELinux context</title>
1825 <para>
1826 If lxc was compiled and installed with SELinux support, and the host
1827 system has SELinux enabled, then the SELinux context under which the
1828 container should be run can be specified in the container
1829 configuration. The default is <command>unconfined_t</command>,
1830 which means that lxc will not attempt to change contexts.
1831 See @DATADIR@/lxc/selinux/lxc.te for an example policy and more
1832 information.
1833 </para>
1834 <variablelist>
1835 <varlistentry>
1836 <term>
1837 <option>lxc.selinux.context</option>
1838 </term>
1839 <listitem>
1840 <para>
1841 Specify the SELinux context under which the container should
1842 be run or <command>unconfined_t</command>. For example
1843 </para>
1844 <programlisting>lxc.selinux.context = system_u:system_r:lxc_t:s0:c22</programlisting>
1845 </listitem>
1846 </varlistentry>
1847 </variablelist>
1848 </refsect2>
1849
1850 <refsect2>
1851 <title>Seccomp configuration</title>
1852 <para>
1853 A container can be started with a reduced set of available
1854 system calls by loading a seccomp profile at startup. The
1855 seccomp configuration file must begin with a version number
1856 on the first line, a policy type on the second line, followed
1857 by the configuration.
1858 </para>
1859 <para>
1860 Versions 1 and 2 are currently supported. In version 1, the
1861 policy is a simple whitelist. The second line therefore must
1862 read "whitelist", with the rest of the file containing one (numeric)
1863 syscall number per line. Each syscall number is whitelisted,
1864 while every unlisted number is blacklisted for use in the container
1865 </para>
1866
1867 <para>
1868 In version 2, the policy may be blacklist or whitelist,
1869 supports per-rule and per-policy default actions, and supports
1870 per-architecture system call resolution from textual names.
1871 </para>
1872 <para>
1873 An example blacklist policy, in which all system calls are
1874 allowed except for mknod, which will simply do nothing and
1875 return 0 (success), looks like:
1876 </para>
1877
1878 <programlisting>
1879 2
1880 blacklist
1881 mknod errno 0
1882 ioctl notify
1883 </programlisting>
1884
1885 <para>
1886 Specifying "errno" as action will cause LXC to register a seccomp filter
1887 that will cause a specific errno to be returned ot the caller. The errno
1888 value can be specified after the "errno" action word.
1889 </para>
1890
1891 <para>
1892 Specifying "notify" as action will cause LXC to register a seccomp
1893 listener and retrieve a listener file descriptor from the kernel. When a
1894 syscall is made that is registered as "notify" the kernel will generate a
1895 poll event and send a message over the file descriptor. The caller can
1896 read this message, inspect the syscalls including its arguments. Based on
1897 this information the caller is expected to send back a message informing
1898 the kernel which action to take. Until that message is sent the kernel
1899 will block the calling process. The format of the messages to read and
1900 sent is documented in seccomp itself.
1901 </para>
1902
1903 <variablelist>
1904 <varlistentry>
1905 <term>
1906 <option>lxc.seccomp.profile</option>
1907 </term>
1908 <listitem>
1909 <para>
1910 Specify a file containing the seccomp configuration to
1911 load before the container starts.
1912 </para>
1913 </listitem>
1914 </varlistentry>
1915 <varlistentry>
1916 <term>
1917 <option>lxc.seccomp.allow_nesting</option>
1918 </term>
1919 <listitem>
1920 <para>
1921 If this flag is set to 1, then seccomp filters will be stacked
1922 regardless of whether a seccomp profile is already loaded.
1923 This allows nested containers to load their own seccomp profile.
1924 The default setting is 0.
1925 </para>
1926 </listitem>
1927 </varlistentry>
1928 <varlistentry>
1929 <term>
1930 <option>lxc.seccomp.notify.proxy</option>
1931 </term>
1932 <listitem>
1933 <para>
1934 Specify a unix socket to which LXC will connect and forward
1935 seccomp events to. The path must by in the form
1936 unix:/path/to/socket or unix:@socket. The former specifies a
1937 path-bound unix domain socket while the latter specifies an
1938 abstract unix domain socket.
1939 </para>
1940 </listitem>
1941 </varlistentry>
1942 </variablelist>
1943 </refsect2>
1944
1945 <refsect2>
1946 <title>PR_SET_NO_NEW_PRIVS</title>
1947 <para>
1948 With PR_SET_NO_NEW_PRIVS active execve() promises not to grant
1949 privileges to do anything that could not have been done without
1950 the execve() call (for example, rendering the set-user-ID and
1951 set-group-ID mode bits, and file capabilities non-functional).
1952 Once set, this bit cannot be unset. The setting of this bit is
1953 inherited by children created by fork() and clone(), and preserved
1954 across execve().
1955 Note that PR_SET_NO_NEW_PRIVS is applied after the container has
1956 changed into its intended AppArmor profile or SElinux context.
1957 </para>
1958 <variablelist>
1959 <varlistentry>
1960 <term>
1961 <option>lxc.no_new_privs</option>
1962 </term>
1963 <listitem>
1964 <para>
1965 Specify whether the PR_SET_NO_NEW_PRIVS flag should be set for the
1966 container. Set to 1 to activate.
1967 </para>
1968 </listitem>
1969 </varlistentry>
1970 </variablelist>
1971 </refsect2>
1972
1973 <refsect2>
1974 <title>UID mappings</title>
1975 <para>
1976 A container can be started in a private user namespace with
1977 user and group id mappings. For instance, you can map userid
1978 0 in the container to userid 200000 on the host. The root
1979 user in the container will be privileged in the container,
1980 but unprivileged on the host. Normally a system container
1981 will want a range of ids, so you would map, for instance,
1982 user and group ids 0 through 20,000 in the container to the
1983 ids 200,000 through 220,000.
1984 </para>
1985 <variablelist>
1986 <varlistentry>
1987 <term>
1988 <option>lxc.idmap</option>
1989 </term>
1990 <listitem>
1991 <para>
1992 Four values must be provided. First a character, either
1993 'u', or 'g', to specify whether user or group ids are
1994 being mapped. Next is the first userid as seen in the
1995 user namespace of the container. Next is the userid as
1996 seen on the host. Finally, a range indicating the number
1997 of consecutive ids to map.
1998 </para>
1999 </listitem>
2000 </varlistentry>
2001 </variablelist>
2002 </refsect2>
2003
2004 <refsect2>
2005 <title>Container hooks</title>
2006 <para>
2007 Container hooks are programs or scripts which can be executed
2008 at various times in a container's lifetime.
2009 </para>
2010 <para>
2011 When a container hook is executed, additional information is passed
2012 along. The <option>lxc.hook.version</option> argument can be used to
2013 determine if the following arguments are passed as command line
2014 arguments or through environment variables. The arguments are:
2015 <itemizedlist>
2016 <listitem><para> Container name. </para></listitem>
2017 <listitem><para> Section (always 'lxc'). </para></listitem>
2018 <listitem><para> The hook type (i.e. 'clone' or 'pre-mount'). </para></listitem>
2019 <listitem><para> Additional arguments. In the
2020 case of the clone hook, any extra arguments passed will appear as
2021 further arguments to the hook. In the case of the stop hook, paths to
2022 filedescriptors for each of the container's namespaces along with
2023 their types are passed. </para></listitem>
2024 </itemizedlist>
2025 The following environment variables are set:
2026 <itemizedlist>
2027 <listitem><para> LXC_CGNS_AWARE: indicator whether the container is
2028 cgroup namespace aware. </para></listitem>
2029 <listitem><para> LXC_CONFIG_FILE: the path to the container
2030 configuration file. </para></listitem>
2031 <listitem><para> LXC_HOOK_TYPE: the hook type (e.g. 'clone', 'mount',
2032 'pre-mount'). Note that the existence of this environment variable is
2033 conditional on the value of <option>lxc.hook.version</option>. If it
2034 is set to 1 then LXC_HOOK_TYPE will be set.
2035 </para></listitem>
2036 <listitem><para> LXC_HOOK_SECTION: the section type (e.g. 'lxc',
2037 'net'). Note that the existence of this environment variable is
2038 conditional on the value of <option>lxc.hook.version</option>. If it
2039 is set to 1 then LXC_HOOK_SECTION will be set.
2040 </para></listitem>
2041 <listitem><para> LXC_HOOK_VERSION: the version of the hooks. This
2042 value is identical to the value of the container's
2043 <option>lxc.hook.version</option> config item. If it is set to 0 then
2044 old-style hooks are used. If it is set to 1 then new-style hooks are
2045 used. </para></listitem>
2046 <listitem><para> LXC_LOG_LEVEL: the container's log level. </para></listitem>
2047 <listitem><para> LXC_NAME: is the container's name. </para></listitem>
2048 <listitem><para> LXC_[NAMESPACE IDENTIFIER]_NS: path under
2049 /proc/PID/fd/ to a file descriptor referring to the container's
2050 namespace. For each preserved namespace type there will be a separate
2051 environment variable. These environment variables will only be set if
2052 <option>lxc.hook.version</option> is set to 1. </para></listitem>
2053 <listitem><para> LXC_ROOTFS_MOUNT: the path to the mounted root filesystem. </para></listitem>
2054 <listitem><para> LXC_ROOTFS_PATH: this is the lxc.rootfs.path entry
2055 for the container. Note this is likely not where the mounted rootfs is
2056 to be found, use LXC_ROOTFS_MOUNT for that. </para></listitem>
2057 <listitem><para> LXC_SRC_NAME: in the case of the clone hook, this is
2058 the original container's name. </para></listitem>
2059 </itemizedlist>
2060 </para>
2061 <para>
2062 Standard output from the hooks is logged at debug level.
2063 Standard error is not logged, but can be captured by the
2064 hook redirecting its standard error to standard output.
2065 </para>
2066 <variablelist>
2067 <varlistentry>
2068 <term>
2069 <option>lxc.hook.version</option>
2070 </term>
2071 <listitem>
2072 <para>
2073 To pass the arguments in new style via environment variables set to
2074 1 otherwise set to 0 to pass them as arguments.
2075 This setting affects all hooks arguments that were traditionally
2076 passed as arguments to the script. Specifically, it affects the
2077 container name, section (e.g. 'lxc', 'net') and hook type (e.g.
2078 'clone', 'mount', 'pre-mount') arguments. If new-style hooks are
2079 used then the arguments will be available as environment variables.
2080 The container name will be set in LXC_NAME. (This is set
2081 independently of the value used for this config item.) The section
2082 will be set in LXC_HOOK_SECTION and the hook type will be set in
2083 LXC_HOOK_TYPE.
2084 It also affects how the paths to file descriptors referring to the
2085 container's namespaces are passed. If set to 1 then for each
2086 namespace a separate environment variable LXC_[NAMESPACE
2087 IDENTIFIER]_NS will be set. If set to 0 then the paths will be
2088 passed as arguments to the stop hook.
2089 </para>
2090 </listitem>
2091 </varlistentry>
2092 </variablelist>
2093 <variablelist>
2094 <varlistentry>
2095 <term>
2096 <option>lxc.hook.pre-start</option>
2097 </term>
2098 <listitem>
2099 <para>
2100 A hook to be run in the host's namespace before the
2101 container ttys, consoles, or mounts are up.
2102 </para>
2103 </listitem>
2104 </varlistentry>
2105 </variablelist>
2106 <variablelist>
2107 <varlistentry>
2108 <term>
2109 <option>lxc.hook.pre-mount</option>
2110 </term>
2111 <listitem>
2112 <para>
2113 A hook to be run in the container's fs namespace but before
2114 the rootfs has been set up. This allows for manipulation
2115 of the rootfs, i.e. to mount an encrypted filesystem. Mounts
2116 done in this hook will not be reflected on the host (apart from
2117 mounts propagation), so they will be automatically cleaned up
2118 when the container shuts down.
2119 </para>
2120 </listitem>
2121 </varlistentry>
2122 </variablelist>
2123 <variablelist>
2124 <varlistentry>
2125 <term>
2126 <option>lxc.hook.mount</option>
2127 </term>
2128 <listitem>
2129 <para>
2130 A hook to be run in the container's namespace after
2131 mounting has been done, but before the pivot_root.
2132 </para>
2133 </listitem>
2134 </varlistentry>
2135 </variablelist>
2136 <variablelist>
2137 <varlistentry>
2138 <term>
2139 <option>lxc.hook.autodev</option>
2140 </term>
2141 <listitem>
2142 <para>
2143 A hook to be run in the container's namespace after
2144 mounting has been done and after any mount hooks have
2145 run, but before the pivot_root, if
2146 <option>lxc.autodev</option> == 1.
2147 The purpose of this hook is to assist in populating the
2148 /dev directory of the container when using the autodev
2149 option for systemd based containers. The container's /dev
2150 directory is relative to the
2151 ${<option>LXC_ROOTFS_MOUNT</option>} environment
2152 variable available when the hook is run.
2153 </para>
2154 </listitem>
2155 </varlistentry>
2156 </variablelist>
2157 <variablelist>
2158 <varlistentry>
2159 <term>
2160 <option>lxc.hook.start-host</option>
2161 </term>
2162 <listitem>
2163 <para>
2164 A hook to be run in the host's namespace after the
2165 container has been setup, and immediately before starting
2166 the container init.
2167 </para>
2168 </listitem>
2169 </varlistentry>
2170 </variablelist>
2171 <variablelist>
2172 <varlistentry>
2173 <term>
2174 <option>lxc.hook.start</option>
2175 </term>
2176 <listitem>
2177 <para>
2178 A hook to be run in the container's namespace immediately
2179 before executing the container's init. This requires the
2180 program to be available in the container.
2181 </para>
2182 </listitem>
2183 </varlistentry>
2184 </variablelist>
2185 <variablelist>
2186 <varlistentry>
2187 <term>
2188 <option>lxc.hook.stop</option>
2189 </term>
2190 <listitem>
2191 <para>
2192 A hook to be run in the host's namespace with references
2193 to the container's namespaces after the container has been shut
2194 down. For each namespace an extra argument is passed to the hook
2195 containing the namespace's type and a filename that can be used to
2196 obtain a file descriptor to the corresponding namespace, separated
2197 by a colon. The type is the name as it would appear in the
2198 <filename>/proc/PID/ns</filename> directory.
2199 For instance for the mount namespace the argument usually looks
2200 like <filename>mnt:/proc/PID/fd/12</filename>.
2201 </para>
2202 </listitem>
2203 </varlistentry>
2204 </variablelist>
2205 <variablelist>
2206 <varlistentry>
2207 <term>
2208 <option>lxc.hook.post-stop</option>
2209 </term>
2210 <listitem>
2211 <para>
2212 A hook to be run in the host's namespace after the
2213 container has been shut down.
2214 </para>
2215 </listitem>
2216 </varlistentry>
2217 </variablelist>
2218 <variablelist>
2219 <varlistentry>
2220 <term>
2221 <option>lxc.hook.clone</option>
2222 </term>
2223 <listitem>
2224 <para>
2225 A hook to be run when the container is cloned to a new one.
2226 See <citerefentry><refentrytitle><command>lxc-clone</command></refentrytitle>
2227 <manvolnum>1</manvolnum></citerefentry> for more information.
2228 </para>
2229 </listitem>
2230 </varlistentry>
2231 </variablelist>
2232 <variablelist>
2233 <varlistentry>
2234 <term>
2235 <option>lxc.hook.destroy</option>
2236 </term>
2237 <listitem>
2238 <para>
2239 A hook to be run when the container is destroyed.
2240 </para>
2241 </listitem>
2242 </varlistentry>
2243 </variablelist>
2244 </refsect2>
2245
2246 <refsect2>
2247 <title>Container hooks Environment Variables</title>
2248 <para>
2249 A number of environment variables are made available to the startup
2250 hooks to provide configuration information and assist in the
2251 functioning of the hooks. Not all variables are valid in all
2252 contexts. In particular, all paths are relative to the host system
2253 and, as such, not valid during the <option>lxc.hook.start</option> hook.
2254 </para>
2255 <variablelist>
2256 <varlistentry>
2257 <term>
2258 <option>LXC_NAME</option>
2259 </term>
2260 <listitem>
2261 <para>
2262 The LXC name of the container. Useful for logging messages
2263 in common log environments. [<option>-n</option>]
2264 </para>
2265 </listitem>
2266 </varlistentry>
2267 </variablelist>
2268 <variablelist>
2269 <varlistentry>
2270 <term>
2271 <option>LXC_CONFIG_FILE</option>
2272 </term>
2273 <listitem>
2274 <para>
2275 Host relative path to the container configuration file. This
2276 gives the container to reference the original, top level,
2277 configuration file for the container in order to locate any
2278 additional configuration information not otherwise made
2279 available. [<option>-f</option>]
2280 </para>
2281 </listitem>
2282 </varlistentry>
2283 </variablelist>
2284 <variablelist>
2285 <varlistentry>
2286 <term>
2287 <option>LXC_CONSOLE</option>
2288 </term>
2289 <listitem>
2290 <para>
2291 The path to the console output of the container if not NULL.
2292 [<option>-c</option>] [<option>lxc.console.path</option>]
2293 </para>
2294 </listitem>
2295 </varlistentry>
2296 </variablelist>
2297 <variablelist>
2298 <varlistentry>
2299 <term>
2300 <option>LXC_CONSOLE_LOGPATH</option>
2301 </term>
2302 <listitem>
2303 <para>
2304 The path to the console log output of the container if not NULL.
2305 [<option>-L</option>]
2306 </para>
2307 </listitem>
2308 </varlistentry>
2309 </variablelist>
2310 <variablelist>
2311 <varlistentry>
2312 <term>
2313 <option>LXC_ROOTFS_MOUNT</option>
2314 </term>
2315 <listitem>
2316 <para>
2317 The mount location to which the container is initially bound.
2318 This will be the host relative path to the container rootfs
2319 for the container instance being started and is where changes
2320 should be made for that instance.
2321 [<option>lxc.rootfs.mount</option>]
2322 </para>
2323 </listitem>
2324 </varlistentry>
2325 </variablelist>
2326 <variablelist>
2327 <varlistentry>
2328 <term>
2329 <option>LXC_ROOTFS_PATH</option>
2330 </term>
2331 <listitem>
2332 <para>
2333 The host relative path to the container root which has been
2334 mounted to the rootfs.mount location.
2335 [<option>lxc.rootfs.path</option>]
2336 </para>
2337 </listitem>
2338 </varlistentry>
2339 </variablelist>
2340 <variablelist>
2341 <varlistentry>
2342 <term>
2343 <option>LXC_SRC_NAME</option>
2344 </term>
2345 <listitem>
2346 <para>
2347 Only for the clone hook. Is set to the original container name.
2348 </para>
2349 </listitem>
2350 </varlistentry>
2351 </variablelist>
2352 <variablelist>
2353 <varlistentry>
2354 <term>
2355 <option>LXC_TARGET</option>
2356 </term>
2357 <listitem>
2358 <para>
2359 Only for the stop hook. Is set to "stop" for a container
2360 shutdown or "reboot" for a container reboot.
2361 </para>
2362 </listitem>
2363 </varlistentry>
2364 </variablelist>
2365 <variablelist>
2366 <varlistentry>
2367 <term>
2368 <option>LXC_CGNS_AWARE</option>
2369 </term>
2370 <listitem>
2371 <para>
2372 If unset, then this version of lxc is not aware of cgroup
2373 namespaces. If set, it will be set to 1, and lxc is aware
2374 of cgroup namespaces. Note this does not guarantee that
2375 cgroup namespaces are enabled in the kernel. This is used
2376 by the lxcfs mount hook.
2377 </para>
2378 </listitem>
2379 </varlistentry>
2380 </variablelist>
2381 </refsect2>
2382 <refsect2>
2383 <title>Logging</title>
2384 <para>
2385 Logging can be configured on a per-container basis. By default,
2386 depending upon how the lxc package was compiled, container startup
2387 is logged only at the ERROR level, and logged to a file named after
2388 the container (with '.log' appended) either under the container path,
2389 or under @LOGPATH@.
2390 </para>
2391 <para>
2392 Both the default log level and the log file can be specified in the
2393 container configuration file, overriding the default behavior. Note
2394 that the configuration file entries can in turn be overridden by the
2395 command line options to <command>lxc-start</command>.
2396 </para>
2397 <variablelist>
2398 <varlistentry>
2399 <term>
2400 <option>lxc.log.level</option>
2401 </term>
2402 <listitem>
2403 <para>
2404 The level at which to log. The log level is an integer in
2405 the range of 0..8 inclusive, where a lower number means more
2406 verbose debugging. In particular 0 = trace, 1 = debug, 2 =
2407 info, 3 = notice, 4 = warn, 5 = error, 6 = critical, 7 =
2408 alert, and 8 = fatal. If unspecified, the level defaults
2409 to 5 (error), so that only errors and above are logged.
2410 </para>
2411 <para>
2412 Note that when a script (such as either a hook script or a
2413 network interface up or down script) is called, the script's
2414 standard output is logged at level 1, debug.
2415 </para>
2416 </listitem>
2417 </varlistentry>
2418 <varlistentry>
2419 <term>
2420 <option>lxc.log.file</option>
2421 </term>
2422 <listitem>
2423 <para>
2424 The file to which logging info should be written.
2425 </para>
2426 </listitem>
2427 </varlistentry>
2428 <varlistentry>
2429 <term>
2430 <option>lxc.log.syslog</option>
2431 </term>
2432 <listitem>
2433 <para>
2434 Send logging info to syslog. It respects the log level defined in
2435 <command>lxc.log.level</command>. The argument should be the syslog
2436 facility to use, valid ones are: daemon, local0, local1, local2,
2437 local3, local4, local5, local5, local6, local7.
2438 </para>
2439 </listitem>
2440 </varlistentry>
2441 </variablelist>
2442 </refsect2>
2443
2444 <refsect2>
2445 <title>Autostart</title>
2446 <para>
2447 The autostart options support marking which containers should be
2448 auto-started and in what order. These options may be used by LXC tools
2449 directly or by external tooling provided by the distributions.
2450 </para>
2451
2452 <variablelist>
2453 <varlistentry>
2454 <term>
2455 <option>lxc.start.auto</option>
2456 </term>
2457 <listitem>
2458 <para>
2459 Whether the container should be auto-started.
2460 Valid values are 0 (off) and 1 (on).
2461 </para>
2462 </listitem>
2463 </varlistentry>
2464 <varlistentry>
2465 <term>
2466 <option>lxc.start.delay</option>
2467 </term>
2468 <listitem>
2469 <para>
2470 How long to wait (in seconds) after the container is
2471 started before starting the next one.
2472 </para>
2473 </listitem>
2474 </varlistentry>
2475 <varlistentry>
2476 <term>
2477 <option>lxc.start.order</option>
2478 </term>
2479 <listitem>
2480 <para>
2481 An integer used to sort the containers when auto-starting
2482 a series of containers at once.
2483 </para>
2484 </listitem>
2485 </varlistentry>
2486 <varlistentry>
2487 <term>
2488 <option>lxc.monitor.unshare</option>
2489 </term>
2490 <listitem>
2491 <para>
2492 If not zero the mount namespace will be unshared from the host
2493 before initializing the container (before running any pre-start
2494 hooks). This requires the CAP_SYS_ADMIN capability at startup.
2495 Default is 0.
2496 </para>
2497 </listitem>
2498 </varlistentry>
2499 <varlistentry>
2500 <term>
2501 <option>lxc.monitor.signal.pdeath</option>
2502 </term>
2503 <listitem>
2504 <para>
2505 Set the signal to be sent to the container's init when the lxc
2506 monitor exits. By default it is set to SIGKILL which will cause
2507 all container processes to be killed when the lxc monitor process
2508 dies.
2509 To ensure that containers stay alive even if lxc monitor dies set
2510 this to 0.
2511 </para>
2512 </listitem>
2513 </varlistentry>
2514 <varlistentry>
2515 <term>
2516 <option>lxc.group</option>
2517 </term>
2518 <listitem>
2519 <para>
2520 A multi-value key (can be used multiple times) to put the
2521 container in a container group. Those groups can then be
2522 used (amongst other things) to start a series of related
2523 containers.
2524 </para>
2525 </listitem>
2526 </varlistentry>
2527 </variablelist>
2528 </refsect2>
2529
2530 <refsect2>
2531 <title>Autostart and System Boot</title>
2532 <para>
2533 Each container can be part of any number of groups or no group at all.
2534 Two groups are special. One is the NULL group, i.e. the container does
2535 not belong to any group. The other group is the "onboot" group.
2536 </para>
2537
2538 <para>
2539 When the system boots with the LXC service enabled, it will first
2540 attempt to boot any containers with lxc.start.auto == 1 that is a member
2541 of the "onboot" group. The startup will be in order of lxc.start.order.
2542 If an lxc.start.delay has been specified, that delay will be honored
2543 before attempting to start the next container to give the current
2544 container time to begin initialization and reduce overloading the host
2545 system. After starting the members of the "onboot" group, the LXC system
2546 will proceed to boot containers with lxc.start.auto == 1 which are not
2547 members of any group (the NULL group) and proceed as with the onboot
2548 group.
2549 </para>
2550
2551 </refsect2>
2552
2553 <refsect2>
2554 <title>Container Environment</title>
2555 <para>
2556 If you want to pass environment variables into the container (that
2557 is, environment variables which will be available to init and all of
2558 its descendents), you can use <command>lxc.environment</command>
2559 parameters to do so. Be careful that you do not pass in anything
2560 sensitive; any process in the container which doesn't have its
2561 environment scrubbed will have these variables available to it, and
2562 environment variables are always available via
2563 <command>/proc/PID/environ</command>.
2564 </para>
2565
2566 <para>
2567 This configuration parameter can be specified multiple times; once
2568 for each environment variable you wish to configure.
2569 </para>
2570
2571 <variablelist>
2572 <varlistentry>
2573 <term>
2574 <option>lxc.environment</option>
2575 </term>
2576 <listitem>
2577 <para>
2578 Specify an environment variable to pass into the container.
2579 Example:
2580 </para>
2581 <programlisting>
2582 lxc.environment = APP_ENV=production
2583 lxc.environment = SYSLOG_SERVER=192.0.2.42
2584 </programlisting>
2585 <para>
2586 It is possible to inherit host environment variables by setting the
2587 name of the variable without a "=" sign. For example:
2588 </para>
2589 <programlisting>
2590 lxc.environment = PATH
2591 </programlisting>
2592 </listitem>
2593 </varlistentry>
2594 </variablelist>
2595 </refsect2>
2596
2597 </refsect1>
2598
2599 <refsect1>
2600 <title>Examples</title>
2601 <para>
2602 In addition to the few examples given below, you will find
2603 some other examples of configuration file in @DOCDIR@/examples
2604 </para>
2605 <refsect2>
2606 <title>Network</title>
2607 <para>This configuration sets up a container to use a veth pair
2608 device with one side plugged to a bridge br0 (which has been
2609 configured before on the system by the administrator). The
2610 virtual network device visible in the container is renamed to
2611 eth0.</para>
2612 <programlisting>
2613 lxc.uts.name = myhostname
2614 lxc.net.0.type = veth
2615 lxc.net.0.flags = up
2616 lxc.net.0.link = br0
2617 lxc.net.0.name = eth0
2618 lxc.net.0.hwaddr = 4a:49:43:49:79:bf
2619 lxc.net.0.ipv4.address = 10.2.3.5/24 10.2.3.255
2620 lxc.net.0.ipv6.address = 2003:db8:1:0:214:1234:fe0b:3597
2621 </programlisting>
2622 </refsect2>
2623
2624 <refsect2>
2625 <title>UID/GID mapping</title>
2626 <para>This configuration will map both user and group ids in the
2627 range 0-9999 in the container to the ids 100000-109999 on the host.
2628 </para>
2629 <programlisting>
2630 lxc.idmap = u 0 100000 10000
2631 lxc.idmap = g 0 100000 10000
2632 </programlisting>
2633 </refsect2>
2634
2635 <refsect2>
2636 <title>Control group</title>
2637 <para>This configuration will setup several control groups for
2638 the application, cpuset.cpus restricts usage of the defined cpu,
2639 cpus.share prioritize the control group, devices.allow makes
2640 usable the specified devices.</para>
2641 <programlisting>
2642 lxc.cgroup.cpuset.cpus = 0,1
2643 lxc.cgroup.cpu.shares = 1234
2644 lxc.cgroup.devices.deny = a
2645 lxc.cgroup.devices.allow = c 1:3 rw
2646 lxc.cgroup.devices.allow = b 8:0 rw
2647 </programlisting>
2648 </refsect2>
2649
2650 <refsect2>
2651 <title>Complex configuration</title>
2652 <para>This example show a complex configuration making a complex
2653 network stack, using the control groups, setting a new hostname,
2654 mounting some locations and a changing root file system.</para>
2655 <programlisting>
2656 lxc.uts.name = complex
2657 lxc.net.0.type = veth
2658 lxc.net.0.flags = up
2659 lxc.net.0.link = br0
2660 lxc.net.0.hwaddr = 4a:49:43:49:79:bf
2661 lxc.net.0.ipv4.address = 10.2.3.5/24 10.2.3.255
2662 lxc.net.0.ipv6.address = 2003:db8:1:0:214:1234:fe0b:3597
2663 lxc.net.0.ipv6.address = 2003:db8:1:0:214:5432:feab:3588
2664 lxc.net.1.type = macvlan
2665 lxc.net.1.flags = up
2666 lxc.net.1.link = eth0
2667 lxc.net.1.hwaddr = 4a:49:43:49:79:bd
2668 lxc.net.1.ipv4.address = 10.2.3.4/24
2669 lxc.net.1.ipv4.address = 192.168.10.125/24
2670 lxc.net.1.ipv6.address = 2003:db8:1:0:214:1234:fe0b:3596
2671 lxc.net.2.type = phys
2672 lxc.net.2.flags = up
2673 lxc.net.2.link = dummy0
2674 lxc.net.2.hwaddr = 4a:49:43:49:79:ff
2675 lxc.net.2.ipv4.address = 10.2.3.6/24
2676 lxc.net.2.ipv6.address = 2003:db8:1:0:214:1234:fe0b:3297
2677 lxc.cgroup.cpuset.cpus = 0,1
2678 lxc.cgroup.cpu.shares = 1234
2679 lxc.cgroup.devices.deny = a
2680 lxc.cgroup.devices.allow = c 1:3 rw
2681 lxc.cgroup.devices.allow = b 8:0 rw
2682 lxc.mount.fstab = /etc/fstab.complex
2683 lxc.mount.entry = /lib /root/myrootfs/lib none ro,bind 0 0
2684 lxc.rootfs.path = dir:/mnt/rootfs.complex
2685 lxc.cap.drop = sys_module mknod setuid net_raw
2686 lxc.cap.drop = mac_override
2687 </programlisting>
2688 </refsect2>
2689
2690 </refsect1>
2691
2692 <refsect1>
2693 <title>See Also</title>
2694 <simpara>
2695 <citerefentry>
2696 <refentrytitle><command>chroot</command></refentrytitle>
2697 <manvolnum>1</manvolnum>
2698 </citerefentry>,
2699
2700 <citerefentry>
2701 <refentrytitle><command>pivot_root</command></refentrytitle>
2702 <manvolnum>8</manvolnum>
2703 </citerefentry>,
2704
2705 <citerefentry>
2706 <refentrytitle><filename>fstab</filename></refentrytitle>
2707 <manvolnum>5</manvolnum>
2708 </citerefentry>,
2709
2710 <citerefentry>
2711 <refentrytitle><filename>capabilities</filename></refentrytitle>
2712 <manvolnum>7</manvolnum>
2713 </citerefentry>
2714 </simpara>
2715 </refsect1>
2716
2717 &seealso;
2718
2719 <refsect1>
2720 <title>Author</title>
2721 <para>Daniel Lezcano <email>daniel.lezcano@free.fr</email></para>
2722 </refsect1>
2723
2724 </refentry>
2725
2726 <!-- Keep this comment at the end of the file
2727 Local variables:
2728 mode: sgml
2729 sgml-omittag:t
2730 sgml-shorttag:t
2731 sgml-minimize-attributes:nil
2732 sgml-always-quote-attributes:t
2733 sgml-indent-step:2
2734 sgml-indent-data:t
2735 sgml-parent-document:nil
2736 sgml-default-dtd-file:nil
2737 sgml-exposed-tags:nil
2738 sgml-local-catalogs:nil
2739 sgml-local-ecat-files:nil
2740 End:
2741 -->