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