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