]> git.proxmox.com Git - mirror_lxc.git/blame - doc/lxc.conf.sgml.in
setup cgroups from parent
[mirror_lxc.git] / doc / lxc.conf.sgml.in
CommitLineData
f79d43bb 1<!--
8a67a2b2 2
3lxc: linux Container library
4
5(C) Copyright IBM Corp. 2007, 2008
6
7Authors:
8Daniel Lezcano <dlezcano at fr.ibm.com>
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
24-->
25
aa8d013e 26<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
99e4008c
MN
27
28<!ENTITY seealso SYSTEM "@builddir@/see_also.sgml">
29]>
8a67a2b2 30
31<refentry>
32
33 <docinfo><date>@LXC_GENERATE_DATE@</date></docinfo>
34
35 <refmeta>
36 <refentrytitle>lxc.conf</refentrytitle>
37 <manvolnum>5</manvolnum>
38 </refmeta>
39
40 <refnamediv>
41 <refname>lxc.conf</refname>
42
43 <refpurpose>
44 linux container configuration file
45 </refpurpose>
46 </refnamediv>
47
48 <refsect1>
49 <title>Description</title>
50
51 <para>
52 The linux containers (<command>lxc</command>) are always created
53 before being used. This creation defines a set of system
54 resources to be virtualized / isolated when a process is using
55 the container. By default, the pids, sysv ipc and mount points
56 are virtualized and isolated. The other system resources are
57 shared across containers, until they are explicitly defined in
58 the configuration file. For example, if there is no network
59 configuration, the network will be shared between the creator of
60 the container and the container itself, but if the network is
61 specified, a new network stack is created for the container and
62 the container can no longer use the network of its ancestor.
63 </para>
64
65 <para>
66 The configuration file defines the different system resources to
67 be assigned for the container. At present, the utsname, the
68 network, the mount points, the root file system and the control
69 groups are supported.
70 </para>
71
72 <para>
73 Each option in the configuration file has the form <command>key
23a92fad 74 = value</command> fitting in one line. The '#' character means
8a67a2b2 75 the line is a comment.
76 </para>
77
cccc74b5
DL
78 <refsect2>
79 <title>Architecture</title>
80 <para>
81 Allows to set the architecture for the container. For example,
82 set a 32bits architecture for a container running 32bits
83 binaries on a 64bits host. That fix the container scripts
84 which rely on the architecture to do some work like
85 downloading the packages.
86 </para>
87
88 <variablelist>
89 <varlistentry>
90 <term>
91 <option>lxc.arch</option>
92 </term>
93 <listitem>
94 <para>
95 Specify the architecture for the container.
96 </para>
97 <para>
98 Valid options are
99 <option>x86</option>,
100 <option>i686</option>,
101 <option>x86_64</option>,
102 <option>amd64</option>
103 </para>
104 </listitem>
105 </varlistentry>
106 </variablelist>
107
108 </refsect2>
109
8a67a2b2 110 <refsect2>
111 <title>Hostname</title>
112 <para>
113 The utsname section defines the hostname to be set for the
114 container. That means the container can set its own hostname
115 without changing the one from the system. That makes the
116 hostname private for the container.
117 </para>
118 <variablelist>
119 <varlistentry>
120 <term>
121 <option>lxc.utsname</option>
122 </term>
123 <listitem>
124 <para>
125 specify the hostname for the container
126 </para>
127 </listitem>
128 </varlistentry>
129 </variablelist>
130 </refsect2>
131
132 <refsect2>
133 <title>Network</title>
134 <para>
135 The network section defines how the network is virtualized in
23a92fad
PF
136 the container. The network virtualization acts at layer
137 two. In order to use the network virtualization, parameters
138 must be specified to define the network interfaces of the
139 container. Several virtual interfaces can be assigned and used
140 in a container even if the system has only one physical
8a67a2b2 141 network interface.
142 </para>
143 <variablelist>
144 <varlistentry>
145 <term>
146 <option>lxc.network.type</option>
147 </term>
148 <listitem>
149 <para>
150 specify what kind of network virtualization to be used
151 for the container. Each time
152 a <option>lxc.network.type</option> field is found a new
23a92fad
PF
153 round of network configuration begins. In this way,
154 several network virtualization types can be specified
155 for the same container, as well as assigning several
156 network interfaces for one container. The different
8a67a2b2 157 virtualization types can be:
158 </para>
159
160 <para>
23a92fad 161 <option>empty:</option> will create only the loopback
8a67a2b2 162 interface.
163 </para>
164
165 <para>
23a92fad
PF
166 <option>veth:</option> a peer network device is created
167 with one side assigned to the container and the other
168 side is attached to a bridge specified by
169 the <option>lxc.network.link</option>. If the bridge is
170 not specified, then the veth pair device will be created
171 but not attached to any bridge. Otherwise, the bridge
172 has to be setup before on the
173 system, <command>lxc</command> won't handle any
174 configuration outside of the container. By
e892973e
DL
175 default <command>lxc</command> choose a name for the
176 network device belonging to the outside of the
177 container, this name is handled
178 by <command>lxc</command>, but if you wish to handle
179 this name yourself, you can tell <command>lxc</command>
180 to set a specific name with
181 the <option>lxc.network.veth.pair</option> option.
182 </para>
183
184 <para>
23a92fad
PF
185 <option>vlan:</option> a vlan interface is linked with
186 the interface specified by
e892973e
DL
187 the <option>lxc.network.link</option> and assigned to
188 the container. The vlan identifier is specified with the
189 option <option>lxc.network.vlan.id</option>.
8a67a2b2 190 </para>
191
192 <para>
23a92fad
PF
193 <option>macvlan:</option> a macvlan interface is linked
194 with the interface specified by
8a67a2b2 195 the <option>lxc.network.link</option> and assigned to
196 the container.
e892973e
DL
197 <option>lxc.network.macvlan.mode</option> specifies the
198 mode the macvlan will use to communicate between
199 different macvlan on the same upper device. The accepted
200 modes are <option>private</option>, the device never
201 communicates with any other device on the same upper_dev (default),
202 <option>vepa</option>, the new Virtual Ethernet Port
203 Aggregator (VEPA) mode, it assumes that the adjacent
204 bridge returns all frames where both source and
205 destination are local to the macvlan port, i.e. the
206 bridge is set up as a reflective relay. Broadcast
207 frames coming in from the upper_dev get flooded to all
208 macvlan interfaces in VEPA mode, local frames are not
209 delivered locallay, or <option>bridge</option>, it
210 provides the behavior of a simple bridge between
211 different macvlan interfaces on the same port. Frames
212 from one interface to another one get delivered directly
213 and are not sent out externally. Broadcast frames get
214 flooded to all other bridge ports and to the external
215 interface, but when they come back from a reflective
216 relay, we don't deliver them again. Since we know all
217 the MAC addresses, the macvlan bridge mode does not
218 require learning or STP like the bridge module does.
8a67a2b2 219 </para>
220
221 <para>
23a92fad
PF
222 <option>phys:</option> an already existing interface
223 specified by the <option>lxc.network.link</option> is
224 assigned to the container.
8a67a2b2 225 </para>
226 </listitem>
227 </varlistentry>
228
229 <varlistentry>
230 <term>
231 <option>lxc.network.flags</option>
232 </term>
233 <listitem>
234 <para>
235 specify an action to do for the
236 network.
237 </para>
f79d43bb 238
8a67a2b2 239 <para><option>up:</option> activates the interface.
240 </para>
241 </listitem>
242 </varlistentry>
243
244 <varlistentry>
245 <term>
246 <option>lxc.network.link</option>
247 </term>
248 <listitem>
249 <para>
250 specify the interface to be used for real network
251 traffic.
252 </para>
253 </listitem>
254 </varlistentry>
255
256 <varlistentry>
257 <term>
258 <option>lxc.network.name</option>
259 </term>
260 <listitem>
261 <para>
23a92fad
PF
262 the interface name is dynamically allocated, but if
263 another name is needed because the configuration files
8a67a2b2 264 being used by the container use a generic name,
265 eg. eth0, this option will rename the interface in the
266 container.
267 </para>
268 </listitem>
269 </varlistentry>
270
271 <varlistentry>
272 <term>
273 <option>lxc.network.hwaddr</option>
274 </term>
275 <listitem>
276 <para>
277 the interface mac address is dynamically allocated by
23a92fad
PF
278 default to the virtual interface, but in some cases,
279 this is needed to resolve a mac address conflict or to
280 always have the same link-local ipv6 address
8a67a2b2 281 </para>
282 </listitem>
283 </varlistentry>
284
285 <varlistentry>
286 <term>
287 <option>lxc.network.ipv4</option>
288 </term>
289 <listitem>
290 <para>
291 specify the ipv4 address to assign to the virtualized
292 interface. Several lines specify several ipv4 addresses.
293 The address is in format x.y.z.t/m,
955f4ce6
DL
294 eg. 192.168.1.123/24. The broadcast address should be
295 specified on the same line, right after the ipv4
296 address.
8a67a2b2 297 </para>
298 </listitem>
299 </varlistentry>
300
be58c6b5
MK
301 <varlistentry>
302 <term>
303 <option>lxc.network.ipv4.gateway</option>
304 </term>
305 <listitem>
306 <para>
307 specify the ipv4 address to use as the gateway inside the
308 container. The address is in format x.y.z.t, eg.
309 192.168.1.123.
310
311 Can also have the special value <option>auto</option>,
312 which means to take the primary address from the bridge
313 interface (as specified by the
314 <option>lxc.network.link</option> option) and use that as
315 the gateway. <option>auto</option> is only available when
316 using the <option>veth</option> and
317 <option>macvlan</option> network types.
318 </para>
319 </listitem>
320 </varlistentry>
321
322
8a67a2b2 323 <varlistentry>
324 <term>
325 <option>lxc.network.ipv6</option>
326 </term>
327 <listitem>
328 <para>
329 specify the ipv6 address to assign to the virtualized
330 interface. Several lines specify several ipv6 addresses.
331 The address is in format x::y/m,
332 eg. 2003:db8:1:0:214:1234:fe0b:3596/64
333 </para>
334 </listitem>
335 </varlistentry>
336
be58c6b5
MK
337 <varlistentry>
338 <term>
339 <option>lxc.network.ipv6.gateway</option>
340 </term>
341 <listitem>
342 <para>
343 specify the ipv6 address to use as the gateway inside the
344 container. The address is in format x::y,
345 eg. 2003:db8:1:0::1
346
347 Can also have the special value <option>auto</option>,
348 which means to take the primary address from the bridge
349 interface (as specified by the
350 <option>lxc.network.link</option> option) and use that as
351 the gateway. <option>auto</option> is only available when
352 using the <option>veth</option> and
353 <option>macvlan</option> network types.
354 </para>
355 </listitem>
356 </varlistentry>
357
6ecad93f
DL
358 <varlistentry>
359 <term>
360 <option>lxc.network.script.up</option>
361 </term>
362 <listitem>
363 <para>
364 add a configuration option to specify a script to be
365 executed after creating and configuring the network used
366 from the host side. The following arguments are passed
367 to the script: container name and config section name
368 (net) Additional arguments depend on the config section
369 employing a script hook; the following are used by the
370 network system: execution context (up), network type
371 (empty/veth/macvlan/phys), Depending on the network
372 type, other arguments may be passed:
373 veth/macvlan/phys. And finally (host-sided) device name.
374 </para>
375 </listitem>
376 </varlistentry>
74a2b586
JK
377
378 <varlistentry>
379 <term>
380 <option>lxc.network.script.down</option>
381 </term>
382 <listitem>
383 <para>
384 add a configuration option to specify a script to be
385 executed before destroying the network used from the
386 host side. The following arguments are passed to the
387 script: container name and config section name (net)
388 Additional arguments depend on the config section
389 employing a script hook; the following are used by the
390 network system: execution context (down), network type
391 (empty/veth/macvlan/phys), Depending on the network
392 type, other arguments may be passed:
393 veth/macvlan/phys. And finally (host-sided) device name.
394 </para>
395 </listitem>
396 </varlistentry>
8a67a2b2 397 </variablelist>
8a67a2b2 398 </refsect2>
399
341a091c 400 <refsect2>
401 <title>New pseudo tty instance (devpts)</title>
402 <para>
403 For stricter isolation the container can have its own private
404 instance of the pseudo tty.
405 </para>
406 <variablelist>
407 <varlistentry>
408 <term>
409 <option>lxc.pts</option>
410 </term>
411 <listitem>
412 <para>
9f78081a 413 If set, the container will have a new pseudo tty
414 instance, making this private to it. The value specifies
415 the maximum number of pseudo ttys allowed for a pts
416 instance (this limitation is not implemented yet).
341a091c 417 </para>
418 </listitem>
419 </varlistentry>
420 </variablelist>
421 </refsect2>
422
765a4e07
DL
423 <refsect2>
424 <title>Container system console</title>
425 <para>
426 If the container is configured with a root filesystem and the
427 inittab file is setup to use the console, you may want to specify
428 where goes the output of this console.
429 </para>
430 <variablelist>
431 <varlistentry>
432 <term>
433 <option>lxc.console</option>
434 </term>
435 <listitem>
436 <para>
437 Specify a path to a file where the console output will
dff21ef0
DL
438 be written. The keyword 'none' will simply disable the
439 console. This is dangerous once if have a rootfs with a
440 console device file where the application can write, the
441 messages will fall in the host.
765a4e07
DL
442 </para>
443 </listitem>
444 </varlistentry>
445 </variablelist>
446 </refsect2>
447
b0a33c1e 448 <refsect2>
449 <title>Console through the ttys</title>
450 <para>
451 If the container is configured with a root filesystem and the
452 inittab file is setup to launch a getty on the ttys. This
453 option will specify the number of ttys to be available for the
454 container. The number of getty in the inittab file of the
23a92fad
PF
455 container should not be greater than the number of ttys
456 specified in this configuration file, otherwise the excess
457 getty sessions will die and respawn indefinitly giving
458 annoying messages on the console.
b0a33c1e 459 </para>
460 <variablelist>
461 <varlistentry>
462 <term>
463 <option>lxc.tty</option>
464 </term>
465 <listitem>
466 <para>
467 Specify the number of tty to make available to the
468 container.
469 </para>
470 </listitem>
471 </varlistentry>
472 </variablelist>
473 </refsect2>
474
1305dd24
SH
475 <refsect2>
476 <title>Console devices location</title>
477 <para>
478 LXC consoles are provided through Unix98 PTYs created on the
479 host and bind-mounted over the expected devices in the container.
480 By default, they are bind-mounted over <filename>/dev/console</filename>
481 and <filename>/dev/ttyN</filename>. This can prevent package upgrades
482 in the guest. Therefore you can specify a directory location (under
483 <filename>/dev</filename> under which LXC will create the files and
484 bind-mount over them. These will then be symbolically linked to
485 <filename>/dev/console</filename> and <filename>/dev/ttyN</filename>.
486 A package upgrade can then succeed as it is able to remove and replace
487 the symbolic links.
488 </para>
489 <variablelist>
490 <varlistentry>
491 <term>
492 <option>lxc.devttydir</option>
493 </term>
494 <listitem>
495 <para>
496 Specify a directory under <filename>/dev</filename>
497 under which to create the container console devices.
498 </para>
499 </listitem>
500 </varlistentry>
501 </variablelist>
502 </refsect2>
503
c6883f38
SH
504 <refsect2>
505 <title>/dev directory</title>
506 <para>
507 By default, lxc does nothing with the container's
508 <filename>/dev</filename>. This allows the container's
509 <filename>/dev</filename> to be set up as needed in the container
ad493d03 510 rootfs. If lxc.autodev is set to 1, then after mounting the container's
c6883f38
SH
511 rootfs LXC will mount a fresh tmpfs under <filename>/dev</filename>
512 (limited to 100k) and fill in a minimal set of initial devices.
f7bee6c6
MW
513 This is generally required when starting a container containing
514 a "systemd" based "init" but may be optional at other times. Addional
515 devices in the containers /dev directory may be created through the
516 use of the <option>lxc.hook.autodev</option> hook.
c6883f38
SH
517 </para>
518 <variablelist>
519 <varlistentry>
520 <term>
521 <option>lxc.autodev</option>
522 </term>
523 <listitem>
524 <para>
525 Set this to 1 to have LXC mount and populate a minimal
526 <filename>/dev</filename> when starting the container.
527 </para>
528 </listitem>
529 </varlistentry>
530 </variablelist>
531 </refsect2>
532
8a67a2b2 533 <refsect2>
534 <title>Mount points</title>
535 <para>
536 The mount points section specifies the different places to be
537 mounted. These mount points will be private to the container
538 and won't be visible by the processes running outside of the
539 container. This is useful to mount /etc, /var or /home for
540 examples.
541 </para>
542 <variablelist>
543 <varlistentry>
544 <term>
545 <option>lxc.mount</option>
546 </term>
547 <listitem>
548 <para>
549 specify a file location in
550 the <filename>fstab</filename> format, containing the
49d3e78d
DL
551 mount informations. If the rootfs is an image file or a
552 device block and the fstab is used to mount a point
553 somewhere in this rootfs, the path of the rootfs mount
554 point should be prefixed with the
555 <filename>@LXCROOTFSMOUNT@</filename> default path or
556 the value of <option>lxc.rootfs.mount</option> if
557 specified.
8a67a2b2 558 </para>
559 </listitem>
560 </varlistentry>
0f71d073
DL
561
562 <varlistentry>
563 <term>
564 <option>lxc.mount.entry</option>
565 </term>
566 <listitem>
567 <para>
568 specify a mount point corresponding to a line in the
569 fstab format.
570 </para>
571 </listitem>
572 </varlistentry>
573
8a67a2b2 574 </variablelist>
575 </refsect2>
576
577 <refsect2>
578 <title>Root file system</title>
579 <para>
64b90b3d
FW
580 The root file system of the container can be different than that
581 of the host system.
8a67a2b2 582 </para>
583 <variablelist>
584 <varlistentry>
585 <term>
586 <option>lxc.rootfs</option>
587 </term>
588 <listitem>
589 <para>
49d3e78d
DL
590 specify the root file system for the container. It can
591 be an image file, a directory or a block device. If not
592 specified, the container shares its root file system
593 with the host.
64b90b3d
FW
594 </para>
595 </listitem>
596 </varlistentry>
597
598 <varlistentry>
599 <term>
600 <option>lxc.rootfs.mount</option>
601 </term>
602 <listitem>
603 <para>
604 where to recursively bind <option>lxc.rootfs</option>
605 before pivoting. This is to ensure success of the
606 <citerefentry>
607 <refentrytitle><command>pivot_root</command></refentrytitle>
608 <manvolnum>8</manvolnum>
609 </citerefentry>
610 syscall. Any directory suffices, the default should
611 generally work.
612 </para>
613 </listitem>
614 </varlistentry>
615
616 <varlistentry>
617 <term>
618 <option>lxc.pivotdir</option>
619 </term>
620 <listitem>
621 <para>
622 where to pivot the original root file system under
623 <option>lxc.rootfs</option>, specified relatively to
3103609d 624 that. The default is <filename>mnt</filename>.
64b90b3d
FW
625 It is created if necessary, and also removed after
626 unmounting everything from it during container setup.
8a67a2b2 627 </para>
628 </listitem>
629 </varlistentry>
630 </variablelist>
631 </refsect2>
632
633 <refsect2>
634 <title>Control group</title>
635 <para>
636 The control group section contains the configuration for the
637 different subsystem. <command>lxc</command> does not check the
23a92fad
PF
638 correctness of the subsystem name. This has the disadvantage
639 of not detecting configuration errors until the container is
640 started, but has the advantage of permitting any future
641 subsystem.
8a67a2b2 642 </para>
643 <variablelist>
644 <varlistentry>
645 <term>
998dc19a 646 <option>lxc.cgroup.[subsystem name]</option>
8a67a2b2 647 </term>
648 <listitem>
649 <para>
23a92fad
PF
650 specify the control group value to be set. The
651 subsystem name is the literal name of the control group
652 subsystem. The permitted names and the syntax of their
653 values is not dictated by LXC, instead it depends on the
654 features of the Linux kernel running at the time the
655 container is started,
8a67a2b2 656 eg. <option>lxc.cgroup.cpuset.cpus</option>
657 </para>
658 </listitem>
659 </varlistentry>
660 </variablelist>
661 </refsect2>
662
81810dd1
DL
663 <refsect2>
664 <title>Capabilities</title>
665 <para>
666 The capabilities can be dropped in the container if this one
667 is run as root.
668 </para>
669 <variablelist>
670 <varlistentry>
671 <term>
672 <option>lxc.cap.drop</option>
673 </term>
674 <listitem>
675 <para>
9eb09f87
DL
676 Specify the capability to be dropped in the container. A
677 single line defining several capabilities with a space
678 separation is allowed. The format is the lower case of
679 the capability definition without the "CAP_" prefix,
81810dd1
DL
680 eg. CAP_SYS_MODULE should be specified as
681 sys_module. See
682 <citerefentry>
683 <refentrytitle><command>capabilities</command></refentrytitle>
9eb09f87 684 <manvolnum>7</manvolnum>
81810dd1
DL
685 </citerefentry>,
686 </para>
687 </listitem>
688 </varlistentry>
689 </variablelist>
690 </refsect2>
691
472c97e9
SH
692 <refsect2>
693 <title>Startup hooks</title>
694 <para>
695 Startup hooks are programs or scripts which can be executed
696 at various times in a container's lifetime.
697 </para>
698 <variablelist>
699 <varlistentry>
700 <term>
701 <option>lxc.hook.pre-start</option>
702 </term>
703 <listitem>
704 <para>
705 A hook to be run in the host's namespace before the
706 container ttys, consoles, or mounts are up.
707 </para>
708 </listitem>
709 </varlistentry>
710 </variablelist>
711 <variablelist>
712 <varlistentry>
713 <term>
714 <option>lxc.hook.pre-mount</option>
715 </term>
716 <listitem>
717 <para>
472c97e9
SH
718 A hook to be run in the container's fs namespace but before
719 the rootfs has been set up. This allows for manipulation
720 of the rootfs, i.e. to mount an encrypted filesystem. Mounts
721 done in this hook will not be reflected on the host (apart from
722 mounts propagation), so they will be automatically cleaned up
723 when the container shuts down.
724 </para>
725 </listitem>
726 </varlistentry>
727 </variablelist>
728 <variablelist>
729 <varlistentry>
730 <term>
731 <option>lxc.hook.mount</option>
732 </term>
733 <listitem>
734 <para>
735 A hook to be run in the container's namespace after
736 mounting has been done, but before the pivot_root.
737 </para>
738 </listitem>
739 </varlistentry>
740 </variablelist>
f7bee6c6
MW
741 <variablelist>
742 <varlistentry>
743 <term>
744 <option>lxc.hook.autodev</option>
745 </term>
746 <listitem>
747 <para>
748 A hook to be run in the container's namespace after
749 mounting has been done and after any mount hooks have
750 run, but before the pivot_root, if
751 <option>lxc.autodev</option> == 1.
752 The purpose of this hook is to assist in populating the
753 /dev directory of the container when using the autodev
754 option for systemd based containers. The container's /dev
755 directory is relative to the
756 ${<option>LXC_ROOTFS_MOUNT</option>} environment
757 variable available when the hook is run.
758 </para>
759 </listitem>
760 </varlistentry>
761 </variablelist>
472c97e9
SH
762 <variablelist>
763 <varlistentry>
764 <term>
765 <option>lxc.hook.start</option>
766 </term>
767 <listitem>
768 <para>
769 A hook to be run in the container's namespace immediately
770 before executing the container's init. This requires the
771 program to be available in the container.
772 </para>
773 </listitem>
774 </varlistentry>
775 </variablelist>
776 <variablelist>
777 <varlistentry>
778 <term>
779 <option>lxc.hook.post-stop</option>
780 </term>
781 <listitem>
782 <para>
783 A hook to be run in the host's namespace after the
784 container has been shut down.
785 </para>
786 </listitem>
787 </varlistentry>
788 </variablelist>
789 </refsect2>
790
f7bee6c6
MW
791 <refsect2>
792 <title>Startup hooks Environment Variables</title>
793 <para>
794 A number of environment variables are made available to the startup
795 hooks to provide configuration information and assist in the
796 functioning of the hooks. Not all variables are valid in all
797 contexts. In particular, all paths are relative to the host system
798 and, as such, not valid during the <option>lxc.hook.start</option> hook.
799 </para>
800 <variablelist>
801 <varlistentry>
802 <term>
803 <option>LXC_NAME</option>
804 </term>
805 <listitem>
806 <para>
807 The LXC name of the container. Useful for logging messages
808 in commmon log environments. [<option>-n</option>]
809 </para>
810 </listitem>
811 </varlistentry>
812 </variablelist>
813 <variablelist>
814 <varlistentry>
815 <term>
816 <option>LXC_CONFIG_FILE</option>
817 </term>
818 <listitem>
819 <para>
820 Host relative path to the container configuration file. This
821 gives the container to reference the original, top level,
822 configuration file for the container in order to locate any
823 addotional configuration information not otherwise made
824 available. [<option>-f</option>]
825 </para>
826 </listitem>
827 </varlistentry>
828 </variablelist>
829 <variablelist>
830 <varlistentry>
831 <term>
832 <option>LXC_CONSOLE</option>
833 </term>
834 <listitem>
835 <para>
836 The path to the console output of the container if not NULL.
837 [<option>-c</option>] [<option>lxc.console</option>]
838 </para>
839 </listitem>
840 </varlistentry>
841 </variablelist>
842 <variablelist>
843 <varlistentry>
844 <term>
845 <option>LXC_CONSOLE_LOGPATH</option>
846 </term>
847 <listitem>
848 <para>
849 The path to the console log output of the container if not NULL.
850 [<option>-L</option>]
851 </para>
852 </listitem>
853 </varlistentry>
854 </variablelist>
855 <variablelist>
856 <varlistentry>
857 <term>
858 <option>LXC_ROOTFS_MOUNT</option>
859 </term>
860 <listitem>
861 <para>
862 The mount location to which the container is initially bound.
863 This will be the host relative path to the container rootfs
864 for the container instance being started and is where changes
865 should be made for that instance.
866 [<option>lxc.rootfs.mount</option>]
867 </para>
868 </listitem>
869 </varlistentry>
870 </variablelist>
871 <variablelist>
872 <varlistentry>
873 <term>
874 <option>LXC_ROOTFS_PATH</option>
875 </term>
876 <listitem>
877 <para>
878 The host relative path to the container root which has been
879 mounted to the rootfs.mount location.
880 [<option>lxc.rootfs</option>]
881 </para>
882 </listitem>
883 </varlistentry>
884 </variablelist>
885
886 </refsect2>
887
8a67a2b2 888 </refsect1>
889
890 <refsect1>
891 <title>Examples</title>
b78b2125
MN
892 <para>
893 In addition to the few examples given below, you will find
894 some other examples of configuration file in @DOCDIR@/examples
895 </para>
8a67a2b2 896 <refsect2>
897 <title>Network</title>
898 <para>This configuration sets up a container to use a veth pair
899 device with one side plugged to a bridge br0 (which has been
900 configured before on the system by the administrator). The
901 virtual network device visible in the container is renamed to
902 eth0.</para>
b78b2125
MN
903 <programlisting>
904 lxc.utsname = myhostname
905 lxc.network.type = veth
906 lxc.network.flags = up
907 lxc.network.link = br0
908 lxc.network.name = eth0
909 lxc.network.hwaddr = 4a:49:43:49:79:bf
5548f218 910 lxc.network.ipv4 = 10.2.3.5/24 10.2.3.255
b78b2125
MN
911 lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3597
912 </programlisting>
8a67a2b2 913 </refsect2>
914
915 <refsect2>
916 <title>Control group</title>
917 <para>This configuration will setup several control groups for
918 the application, cpuset.cpus restricts usage of the defined cpu,
919 cpus.share prioritize the control group, devices.allow makes
920 usable the specified devices.</para>
b78b2125
MN
921 <programlisting>
922 lxc.cgroup.cpuset.cpus = 0,1
923 lxc.cgroup.cpu.shares = 1234
924 lxc.cgroup.devices.deny = a
925 lxc.cgroup.devices.allow = c 1:3 rw
926 lxc.cgroup.devices.allow = b 8:0 rw
927 </programlisting>
8a67a2b2 928 </refsect2>
929
930 <refsect2>
931 <title>Complex configuration</title>
932 <para>This example show a complex configuration making a complex
933 network stack, using the control groups, setting a new hostname,
b78b2125
MN
934 mounting some locations and a changing root file system.</para>
935 <programlisting>
936 lxc.utsname = complex
937 lxc.network.type = veth
938 lxc.network.flags = up
939 lxc.network.link = br0
940 lxc.network.hwaddr = 4a:49:43:49:79:bf
5548f218 941 lxc.network.ipv4 = 10.2.3.5/24 10.2.3.255
b78b2125
MN
942 lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3597
943 lxc.network.ipv6 = 2003:db8:1:0:214:5432:feab:3588
944 lxc.network.type = macvlan
945 lxc.network.flags = up
946 lxc.network.link = eth0
947 lxc.network.hwaddr = 4a:49:43:49:79:bd
5548f218 948 lxc.network.ipv4 = 10.2.3.4/24
b78b2125
MN
949 lxc.network.ipv4 = 192.168.10.125/24
950 lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3596
951 lxc.network.type = phys
952 lxc.network.flags = up
953 lxc.network.link = dummy0
954 lxc.network.hwaddr = 4a:49:43:49:79:ff
5548f218 955 lxc.network.ipv4 = 10.2.3.6/24
b78b2125
MN
956 lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3297
957 lxc.cgroup.cpuset.cpus = 0,1
958 lxc.cgroup.cpu.shares = 1234
959 lxc.cgroup.devices.deny = a
960 lxc.cgroup.devices.allow = c 1:3 rw
961 lxc.cgroup.devices.allow = b 8:0 rw
962 lxc.mount = /etc/fstab.complex
963 lxc.mount.entry = /lib /root/myrootfs/lib none ro,bind 0 0
964 lxc.rootfs = /mnt/rootfs.complex
965 lxc.cap.drop = sys_module mknod setuid net_raw
966 lxc.cap.drop = mac_override
967 </programlisting>
8a67a2b2 968 </refsect2>
969
970 </refsect1>
971
972 <refsect1>
973 <title>See Also</title>
f79d43bb 974 <simpara>
8a67a2b2 975 <citerefentry>
976 <refentrytitle><command>chroot</command></refentrytitle>
977 <manvolnum>1</manvolnum>
978 </citerefentry>,
979
980 <citerefentry>
981 <refentrytitle><command>pivot_root</command></refentrytitle>
982 <manvolnum>8</manvolnum>
983 </citerefentry>,
984
985 <citerefentry>
986 <refentrytitle><filename>fstab</filename></refentrytitle>
987 <manvolnum>5</manvolnum>
988 </citerefentry>
989
990 </simpara>
991 </refsect1>
f79d43bb 992
99e4008c
MN
993 &seealso;
994
8a67a2b2 995 <refsect1>
996 <title>Author</title>
997 <para>Daniel Lezcano <email>daniel.lezcano@free.fr</email></para>
998 </refsect1>
f79d43bb 999
8a67a2b2 1000</refentry>
1001
1002<!-- Keep this comment at the end of the file
1003Local variables:
1004mode: sgml
1005sgml-omittag:t
1006sgml-shorttag:t
1007sgml-minimize-attributes:nil
1008sgml-always-quote-attributes:t
1009sgml-indent-step:2
1010sgml-indent-data:t
1011sgml-parent-document:nil
1012sgml-default-dtd-file:nil
1013sgml-exposed-tags:nil
1014sgml-local-catalogs:nil
1015sgml-local-ecat-files:nil
1016End:
1017-->