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