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