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