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