3 lxc: linux Container library
5 (C) Copyright IBM Corp. 2007, 2008
8 Daniel Lezcano <daniel.lezcano at free.fr>
10 This library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Lesser General Public
12 License as published by the Free Software Foundation; either
13 version 2.1 of the License, or (at your option) any later version.
15 This library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
20 You should have received a copy of the GNU Lesser General Public
21 License along with this library; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26 <!DOCTYPE refentry PUBLIC @docdtd@ [
28 <!ENTITY seealso SYSTEM "@builddir@/see_also.sgml">
33 <docinfo><date>@LXC_GENERATE_DATE@</date></docinfo>
36 <refentrytitle>lxc.container.conf</refentrytitle>
37 <manvolnum>5</manvolnum>
41 <refname>lxc.container.conf</refname>
44 LXC container configuration file
49 <title>Description</title>
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.
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.
67 This is achieved through a combination of kernel security features such as
68 namespaces, mandatory access control and control groups.
72 LXC has supports unprivileged containers. Unprivileged containers are
73 containers that are run without any privilege. This requires support for
74 user namespaces in the kernel that the container is run on. LXC was the
75 first runtime to support unprivileged containers after user namespaces
76 were merged into the mainline kernel.
80 In essence, user namespaces isolate given sets of UIDs and GIDs. This is
81 achieved by establishing a mapping between a range of UIDs and GIDs on the
82 host to a different (unprivileged) range of UIDs and GIDs in the
83 container. The kernel will translate this mapping in such a way that
84 inside the container all UIDs and GIDs appear as you would expect from the
85 host whereas on the host these UIDs and GIDs are in fact unprivileged. For
86 example, a process running as UID and GID 0 inside the container might
87 appear as UID and GID 100000 on the host. The implementation and working
88 details can be gathered from the corresponding user namespace man page.
89 UID and GID mappings can be defined with the <option>lxc.idmap</option>
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.
102 LXC namespaces configuration keys by using single dots. This means complex
103 configuration keys such as <option>lxc.net.0</option> expose various
104 subkeys such as <option>lxc.net.0.type</option>,
105 <option>lxc.net.0.link</option>, <option>lxc.net.0.ipv6.address</option>, and
106 others for even more fine-grained configuration.
110 <title>Configuration</title>
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.
122 <option>lxc.include</option>
126 Specify the file to be included. The included file must be
127 in the same valid lxc configuration file format.
135 <title>Architecture</title>
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.
146 <option>lxc.arch</option>
150 Specify the architecture for the container.
153 Some valid options are
154 <option>x86</option>,
155 <option>i686</option>,
156 <option>x86_64</option>,
157 <option>amd64</option>
166 <title>Hostname</title>
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.
175 <option>lxc.uts.name</option>
179 specify the hostname for the container
187 <title>Halt signal</title>
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
199 <option>lxc.signal.halt</option>
203 specify the signal used to halt the container
211 <title>Reboot signal</title>
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
221 <option>lxc.signal.reboot</option>
225 specify the signal used to reboot the container
233 <title>Stop signal</title>
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
243 <option>lxc.signal.stop</option>
247 specify the signal used to stop the container
255 <title>Init command</title>
257 Sets the command to use as the init system for the containers.
262 <option>lxc.execute.cmd</option>
266 Absolute path from container rootfs to the binary to run by default. This
267 mostly makes sense for <command>lxc-execute</command>.
275 <option>lxc.init.cmd</option>
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>.
288 <title>Init working directory</title>
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.
296 <option>lxc.init.cwd</option>
300 Absolute path inside the container to use as the working directory.
308 <title>Init ID</title>
310 Sets the UID/GID to use for the init system, and subsequent commands.
311 Note that using a non-root UID when booting a system container will
312 likely not work due to missing privileges. Setting the UID/GID is mostly
313 useful when running application containers.
315 Defaults to: UID(0), GID(0)
320 <option>lxc.init.uid</option>
330 <option>lxc.init.gid</option>
344 Configure proc filesystem for the container.
349 <option>lxc.proc.[proc file name]</option>
353 Specify the proc file name to be set. The file name available
354 are those listed under /proc/PID/.
358 lxc.proc.oom_score_adj = 10
366 <title>Ephemeral</title>
368 Allows one to specify whether a container will be destroyed on shutdown.
373 <option>lxc.ephemeral</option>
377 The only allowed values are 0 and 1. Set this to 1 to destroy a
378 container on shutdown.
386 <title>Network</title>
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
399 <option>lxc.net</option>
403 may be used without a value to clear all previous network options.
409 <option>lxc.net.[i].type</option>
413 specify what kind of network virtualization to be used
415 Multiple networks can be specified by using an additional index
417 after all <option>lxc.net.*</option> keys. For example,
418 <option>lxc.net.0.type = veth</option> and
419 <option>lxc.net.1.type = veth</option> specify two different
420 networks of the same type. All keys sharing the same index
421 <option>i</option> will be treated as belonging to the same
422 network. For example, <option>lxc.net.0.link = br0</option>
423 will belong to <option>lxc.net.0.type</option>.
424 Currently, the different virtualization types can be:
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
437 <option>empty:</option> will create only the loopback
442 <option>veth:</option> a virtual ethernet pair
443 device is created with one side assigned to the container
444 and the other side attached to a bridge specified by
445 the <option>lxc.net.[i].link</option> option.
446 If the bridge is not specified, then the veth pair device
447 will be created but not attached to any bridge.
448 Otherwise, the bridge has to be created on the system
449 before starting the container.
450 <command>lxc</command> won't handle any
451 configuration outside of the container.
452 By default, <command>lxc</command> chooses a name for the
453 network device belonging to the outside of the
454 container, but if you wish to handle
455 this name yourselves, you can tell <command>lxc</command>
456 to set a specific name with
457 the <option>lxc.net.[i].veth.pair</option> option (except for
458 unprivileged containers where this option is ignored for security
463 <option>vlan:</option> a vlan interface is linked with
464 the interface specified by
465 the <option>lxc.net.[i].link</option> and assigned to
466 the container. The vlan identifier is specified with the
467 option <option>lxc.net.[i].vlan.id</option>.
471 <option>macvlan:</option> a macvlan interface is linked
472 with the interface specified by
473 the <option>lxc.net.[i].link</option> and assigned to
475 <option>lxc.net.[i].macvlan.mode</option> specifies the
476 mode the macvlan will use to communicate between
477 different macvlan on the same upper device. The accepted
478 modes are <option>private</option>, <option>vepa</option>,
479 <option>bridge</option> and <option>passthru</option>.
480 In <option>private</option> mode, the device never
481 communicates with any other device on the same upper_dev (default).
482 In <option>vepa</option> mode, the new Virtual Ethernet Port
483 Aggregator (VEPA) mode, it assumes that the adjacent
484 bridge returns all frames where both source and
485 destination are local to the macvlan port, i.e. the
486 bridge is set up as a reflective relay. Broadcast
487 frames coming in from the upper_dev get flooded to all
488 macvlan interfaces in VEPA mode, local frames are not
489 delivered locally. In <option>bridge</option> mode, it
490 provides the behavior of a simple bridge between
491 different macvlan interfaces on the same port. Frames
492 from one interface to another one get delivered directly
493 and are not sent out externally. Broadcast frames get
494 flooded to all other bridge ports and to the external
495 interface, but when they come back from a reflective
496 relay, we don't deliver them again. Since we know all
497 the MAC addresses, the macvlan bridge mode does not
498 require learning or STP like the bridge module does. In
499 <option>passthru</option> mode, all frames received by
500 the physical interface are forwarded to the macvlan
501 interface. Only one macvlan interface in <option>passthru</option>
502 mode is possible for one physical interface.
506 <option>phys:</option> an already existing interface
507 specified by the <option>lxc.net.[i].link</option> is
508 assigned to the container.
515 <option>lxc.net.[i].flags</option>
519 Specify an action to do for the network.
522 <para><option>up:</option> activates the interface.
529 <option>lxc.net.[i].link</option>
533 Specify the interface to be used for real network traffic.
540 <option>lxc.net.[i].mtu</option>
544 Specify the maximum transfer unit for this interface.
551 <option>lxc.net.[i].name</option>
555 The interface name is dynamically allocated, but if another name
556 is needed because the configuration files being used by the
557 container use a generic name, eg. eth0, this option will rename
558 the interface in the container.
565 <option>lxc.net.[i].hwaddr</option>
569 The interface mac address is dynamically allocated by default to
570 the virtual interface, but in some cases, this is needed to
571 resolve a mac address conflict or to always have the same
572 link-local ipv6 address. Any "x" in address will be replaced by
573 random value, this allows setting hwaddr templates.
580 <option>lxc.net.[i].ipv4.address</option>
584 Specify the ipv4 address to assign to the virtualized interface.
585 Several lines specify several ipv4 addresses. The address is in
586 format x.y.z.t/m, eg. 192.168.1.123/24.
593 <option>lxc.net.[i].ipv4.gateway</option>
597 Specify the ipv4 address to use as the gateway inside the
598 container. The address is in format x.y.z.t, eg. 192.168.1.123.
600 Can also have the special value <option>auto</option>,
601 which means to take the primary address from the bridge
602 interface (as specified by the
603 <option>lxc.net.[i].link</option> option) and use that as
604 the gateway. <option>auto</option> is only available when
605 using the <option>veth</option> and
606 <option>macvlan</option> network types.
613 <option>lxc.net.[i].ipv6.address</option>
617 Specify the ipv6 address to assign to the virtualized
618 interface. Several lines specify several ipv6 addresses. The
619 address is in format x::y/m, eg.
620 2003:db8:1:0:214:1234:fe0b:3596/64
627 <option>lxc.net.[i].ipv6.gateway</option>
631 Specify the ipv6 address to use as the gateway inside the
632 container. The address is in format x::y, eg. 2003:db8:1:0::1
634 Can also have the special value <option>auto</option>,
635 which means to take the primary address from the bridge
636 interface (as specified by the
637 <option>lxc.net.[i].link</option> option) and use that as
638 the gateway. <option>auto</option> is only available when
639 using the <option>veth</option> and
640 <option>macvlan</option> network types.
647 <option>lxc.net.[i].script.up</option>
651 Add a configuration option to specify a script to be
652 executed after creating and configuring the network used
657 In addition to the information available to all hooks. The
658 following information is provided to the script:
662 LXC_HOOK_TYPE: the hook type. This is either 'up' or 'down'.
668 LXC_HOOK_SECTION: the section type 'net'.
674 LXC_NET_TYPE: the network type. This is one of the valid
675 network types listed here (e.g. 'macvlan', 'veth').
681 LXC_NET_PARENT: the parent device on the host. This is only
682 set for network types 'mavclan', 'veth', 'phys'.
688 LXC_NET_PEER: the name of the peer device on the host. This is
689 only set for 'veth' network types. Note that this information
690 is only available when <option>lxc.hook.version</option> is set
696 Whether this information is provided in the form of environment
697 variables or as arguments to the script depends on the value of
698 <option>lxc.hook.version</option>. If set to 1 then information is
699 provided in the form of environment variables. If set to 0
700 information is provided as arguments to the script.
704 Standard output from the script is logged at debug level.
705 Standard error is not logged, but can be captured by the
706 hook redirecting its standard error to standard output.
713 <option>lxc.net.[i].script.down</option>
717 Add a configuration option to specify a script to be
718 executed before destroying the network used from the
723 In addition to the information available to all hooks. The
724 following information is provided to the script:
728 LXC_HOOK_TYPE: the hook type. This is either 'up' or 'down'.
734 LXC_HOOK_SECTION: the section type 'net'.
740 LXC_NET_TYPE: the network type. This is one of the valid
741 network types listed here (e.g. 'macvlan', 'veth').
747 LXC_NET_PARENT: the parent device on the host. This is only
748 set for network types 'mavclan', 'veth', 'phys'.
754 LXC_NET_PEER: the name of the peer device on the host. This is
755 only set for 'veth' network types. Note that this information
756 is only available when <option>lxc.hook.version</option> is set
762 Whether this information is provided in the form of environment
763 variables or as arguments to the script depends on the value of
764 <option>lxc.hook.version</option>. If set to 1 then information is
765 provided in the form of environment variables. If set to 0
766 information is provided as arguments to the script.
770 Standard output from the script is logged at debug level.
771 Standard error is not logged, but can be captured by the
772 hook redirecting its standard error to standard output.
780 <title>New pseudo tty instance (devpts)</title>
782 For stricter isolation the container can have its own private
783 instance of the pseudo tty.
788 <option>lxc.pty.max</option>
792 If set, the container will have a new pseudo tty
793 instance, making this private to it. The value specifies
794 the maximum number of pseudo ttys allowed for a pts
795 instance (this limitation is not implemented yet).
803 <title>Container system console</title>
805 If the container is configured with a root filesystem and the
806 inittab file is setup to use the console, you may want to specify
807 where the output of this console goes.
813 <option>lxc.console.buffer.size</option>
817 Setting this option instructs liblxc to allocate an in-memory
818 ringbuffer. The container's console output will be written to the
819 ringbuffer. Note that ringbuffer must be at least as big as a
820 standard page size. When passed a value smaller than a single page
821 size liblxc will allocate a ringbuffer of a single page size. A page
824 The keyword 'auto' will cause liblxc to allocate a ringbuffer of
827 When manually specifying a size for the ringbuffer the value should
828 be a power of 2 when converted to bytes. Valid size prefixes are
829 'KB', 'MB', 'GB'. (Note that all conversions are based on multiples
830 of 1024. That means 'KB' == 'KiB', 'MB' == 'MiB', 'GB' == 'GiB'.
831 And ignored case, for example 'kB', 'KB' and 'Kb' is same.)
838 <option>lxc.console.size</option>
842 Setting this option instructs liblxc to place a limit on the size of
843 the console log file specified in
844 <option>lxc.console.logfile</option>. Note that size of the log file
845 must be at least as big as a standard page size. When passed a value
846 smaller than a single page size liblxc will set the size of log file
847 to a single page size. A page size is usually 4KB.
849 The keyword 'auto' will cause liblxc to place a limit of 128KB on
852 When manually specifying a size for the log file the value should
853 be a power of 2 when converted to bytes. Valid size prefixes are
854 'KB', 'MB', 'GB'. (Note that all conversions are based on multiples
855 of 1024. That means 'KB' == 'KiB', 'MB' == 'MiB', 'GB' == 'GiB'.
856 And ignored case, for example 'kB', 'KB' and 'Kb' is same.)
858 If users want to mirror the console ringbuffer on disk they should set
859 <option>lxc.console.size</option> equal to
860 <option>lxc.console.buffer.size</option>.
867 <option>lxc.console.logfile</option>
871 Specify a path to a file where the console output will be written.
872 Note that in contrast to the on-disk ringbuffer logfile this file
873 will keep growing potentially filling up the users disks if not
874 rotated and deleted. This problem can also be avoided by using the
875 in-memory ringbuffer options
876 <option>lxc.console.buffer.size</option> and
877 <option>lxc.console.buffer.logfile</option>.
884 <option>lxc.console.rotate</option>
888 Whether to rotate the console logfile specified in
889 <option>lxc.console.logfile</option>. Users can send an API
890 request to rotate the logfile. Note that the old logfile will have
891 the same name as the original with the suffix ".1" appended.
893 Users wishing to prevent the console log file from filling the
894 disk should rotate the logfile and delete it if unneeded. This
895 problem can also be avoided by using the in-memory ringbuffer
896 options <option>lxc.console.buffer.size</option> and
897 <option>lxc.console.buffer.logfile</option>.
904 <option>lxc.console.path</option>
908 Specify a path to a device to which the console will be
909 attached. The keyword 'none' will simply disable the
910 console. Note, when specifying 'none' and creating a device node
911 for the console in the container at /dev/console or bind-mounting
912 the hosts's /dev/console into the container at /dev/console the
913 container will have direct access to the hosts's /dev/console.
914 This is dangerous when the container has write access to the
915 device and should thus be used with caution.
923 <title>Console through the ttys</title>
925 This option is useful if the container is configured with a root
926 filesystem and the inittab file is setup to launch a getty on the
927 ttys. The option specifies the number of ttys to be available for
928 the container. The number of gettys in the inittab file of the
929 container should not be greater than the number of ttys specified
930 in this option, otherwise the excess getty sessions will die and
931 respawn indefinitely giving annoying messages on the console or in
932 <filename>/var/log/messages</filename>.
937 <option>lxc.tty.max</option>
941 Specify the number of tty to make available to the
950 <title>Console devices location</title>
952 LXC consoles are provided through Unix98 PTYs created on the
953 host and bind-mounted over the expected devices in the container.
954 By default, they are bind-mounted over <filename>/dev/console</filename>
955 and <filename>/dev/ttyN</filename>. This can prevent package upgrades
956 in the guest. Therefore you can specify a directory location (under
957 <filename>/dev</filename> under which LXC will create the files and
958 bind-mount over them. These will then be symbolically linked to
959 <filename>/dev/console</filename> and <filename>/dev/ttyN</filename>.
960 A package upgrade can then succeed as it is able to remove and replace
966 <option>lxc.tty.dir</option>
970 Specify a directory under <filename>/dev</filename>
971 under which to create the container console devices. Note that LXC
972 will move any bind-mounts or device nodes for /dev/console into
981 <title>/dev directory</title>
983 By default, lxc creates a few symbolic links (fd,stdin,stdout,stderr)
984 in the container's <filename>/dev</filename> directory but does not
985 automatically create device node entries. This allows the container's
986 <filename>/dev</filename> to be set up as needed in the container
987 rootfs. If lxc.autodev is set to 1, then after mounting the container's
988 rootfs LXC will mount a fresh tmpfs under <filename>/dev</filename>
989 (limited to 500k) and fill in a minimal set of initial devices.
990 This is generally required when starting a container containing
991 a "systemd" based "init" but may be optional at other times. Additional
992 devices in the containers /dev directory may be created through the
993 use of the <option>lxc.hook.autodev</option> hook.
998 <option>lxc.autodev</option>
1002 Set this to 0 to stop LXC from mounting and populating a minimal
1003 <filename>/dev</filename> when starting the container.
1011 <title>Mount points</title>
1013 The mount points section specifies the different places to be
1014 mounted. These mount points will be private to the container
1015 and won't be visible by the processes running outside of the
1016 container. This is useful to mount /etc, /var or /home for
1020 NOTE - LXC will generally ensure that mount targets and relative
1021 bind-mount sources are properly confined under the container
1022 root, to avoid attacks involving over-mounting host directories
1023 and files. (Symbolic links in absolute mount sources are ignored)
1024 However, if the container configuration first mounts a directory which
1025 is under the control of the container user, such as /home/joe, into
1026 the container at some <filename>path</filename>, and then mounts
1027 under <filename>path</filename>, then a TOCTTOU attack would be
1028 possible where the container user modifies a symbolic link under
1029 his home directory at just the right time.
1034 <option>lxc.mount.fstab</option>
1038 specify a file location in
1039 the <filename>fstab</filename> format, containing the
1040 mount information. The mount target location can and in
1041 most cases should be a relative path, which will become
1042 relative to the mounted container root. For instance,
1045 proc proc proc nodev,noexec,nosuid 0 0
1048 Will mount a proc filesystem under the container's /proc,
1049 regardless of where the root filesystem comes from. This
1050 is resilient to block device backed filesystems as well as
1054 Note that when mounting a filesystem from an
1055 image file or block device the third field (fs_vfstype)
1056 cannot be auto as with
1058 <refentrytitle>mount</refentrytitle>
1059 <manvolnum>8</manvolnum>
1061 but must be explicitly specified.
1068 <option>lxc.mount.entry</option>
1072 Specify a mount point corresponding to a line in the
1075 Moreover lxc supports mount propagation, such as rslave or
1076 rprivate, and adds three additional mount options.
1077 <option>optional</option> don't fail if mount does not work.
1078 <option>create=dir</option> or <option>create=file</option>
1079 to create dir (or file) when the point will be mounted.
1080 <option>relative</option> source path is taken to be relative to
1081 the mounted container root. For instance,
1084 dev/null proc/kcore none bind,relative 0 0
1087 Will expand dev/null to ${<option>LXC_ROOTFS_MOUNT</option>}/dev/null,
1088 and mount it to proc/kcore inside the container.
1095 <option>lxc.mount.auto</option>
1099 specify which standard kernel file systems should be
1100 automatically mounted. This may dramatically simplify
1101 the configuration. The file systems are:
1106 <option>proc:mixed</option> (or <option>proc</option>):
1107 mount <filename>/proc</filename> as read-write, but
1108 remount <filename>/proc/sys</filename> and
1109 <filename>/proc/sysrq-trigger</filename> read-only
1110 for security / container isolation purposes.
1115 <option>proc:rw</option>: mount
1116 <filename>/proc</filename> as read-write
1121 <option>sys:mixed</option> (or <option>sys</option>):
1122 mount <filename>/sys</filename> as read-only but with
1123 /sys/devices/virtual/net writable.
1128 <option>sys:ro</option>:
1129 mount <filename>/sys</filename> as read-only
1130 for security / container isolation purposes.
1135 <option>sys:rw</option>: mount
1136 <filename>/sys</filename> as read-write
1142 <option>cgroup:mixed</option>:
1143 Mount a tmpfs to <filename>/sys/fs/cgroup</filename>,
1144 create directories for all hierarchies to which the container
1145 is added, create subdirectories in those hierarchies with the
1146 name of the cgroup, and bind-mount the container's own cgroup
1147 into that directory. The container will be able to write to
1148 its own cgroup directory, but not the parents, since they will
1149 be remounted read-only.
1155 <option>cgroup:mixed:force</option>:
1156 The <option>force</option> option will cause LXC to perform
1157 the cgroup mounts for the container under all circumstances.
1158 Otherwise it is similar to <option>cgroup:mixed</option>.
1159 This is mainly useful when the cgroup namespaces are enabled
1160 where LXC will normally leave mounting cgroups to the init
1161 binary of the container since it is perfectly safe to do so.
1167 <option>cgroup:ro</option>:
1168 similar to <option>cgroup:mixed</option>, but everything will
1169 be mounted read-only.
1175 <option>cgroup:ro:force</option>:
1176 The <option>force</option> option will cause LXC to perform
1177 the cgroup mounts for the container under all circumstances.
1178 Otherwise it is similar to <option>cgroup:ro</option>.
1179 This is mainly useful when the cgroup namespaces are enabled
1180 where LXC will normally leave mounting cgroups to the init
1181 binary of the container since it is perfectly safe to do so.
1187 <option>cgroup:rw</option>: similar to
1188 <option>cgroup:mixed</option>, but everything will be mounted
1189 read-write. Note that the paths leading up to the container's
1190 own cgroup will be writable, but will not be a cgroup
1191 filesystem but just part of the tmpfs of
1192 <filename>/sys/fs/cgroup</filename>
1198 <option>cgroup:rw:force</option>:
1199 The <option>force</option> option will cause LXC to perform
1200 the cgroup mounts for the container under all circumstances.
1201 Otherwise it is similar to <option>cgroup:rw</option>.
1202 This is mainly useful when the cgroup namespaces are enabled
1203 where LXC will normally leave mounting cgroups to the init
1204 binary of the container since it is perfectly safe to do so.
1210 <option>cgroup</option> (without specifier):
1211 defaults to <option>cgroup:rw</option> if the
1212 container retains the CAP_SYS_ADMIN capability,
1213 <option>cgroup:mixed</option> otherwise.
1219 <option>cgroup-full:mixed</option>:
1220 mount a tmpfs to <filename>/sys/fs/cgroup</filename>,
1221 create directories for all hierarchies to which
1222 the container is added, bind-mount the hierarchies
1223 from the host to the container and make everything
1224 read-only except the container's own cgroup. Note
1225 that compared to <option>cgroup</option>, where
1226 all paths leading up to the container's own cgroup
1227 are just simple directories in the underlying
1229 <filename>/sys/fs/cgroup/$hierarchy</filename>
1230 will contain the host's full cgroup hierarchy,
1231 albeit read-only outside the container's own cgroup.
1232 This may leak quite a bit of information into the
1239 <option>cgroup-full:mixed:force</option>:
1240 The <option>force</option> option will cause LXC to perform
1241 the cgroup mounts for the container under all circumstances.
1242 Otherwise it is similar to <option>cgroup-full:mixed</option>.
1243 This is mainly useful when the cgroup namespaces are enabled
1244 where LXC will normally leave mounting cgroups to the init
1245 binary of the container since it is perfectly safe to do so.
1251 <option>cgroup-full:ro</option>: similar to
1252 <option>cgroup-full:mixed</option>, but everything
1253 will be mounted read-only.
1259 <option>cgroup-full:ro:force</option>:
1260 The <option>force</option> option will cause LXC to perform
1261 the cgroup mounts for the container under all circumstances.
1262 Otherwise it is similar to <option>cgroup-full:ro</option>.
1263 This is mainly useful when the cgroup namespaces are enabled
1264 where LXC will normally leave mounting cgroups to the init
1265 binary of the container since it is perfectly safe to do so.
1271 <option>cgroup-full:rw</option>: similar to
1272 <option>cgroup-full:mixed</option>, but everything
1273 will be mounted read-write. Note that in this case,
1274 the container may escape its own cgroup. (Note also
1275 that if the container has CAP_SYS_ADMIN support
1276 and can mount the cgroup filesystem itself, it may
1283 <option>cgroup-full:rw:force</option>:
1284 The <option>force</option> option will cause LXC to perform
1285 the cgroup mounts for the container under all circumstances.
1286 Otherwise it is similar to <option>cgroup-full:rw</option>.
1287 This is mainly useful when the cgroup namespaces are enabled
1288 where LXC will normally leave mounting cgroups to the init
1289 binary of the container since it is perfectly safe to do so.
1295 <option>cgroup-full</option> (without specifier):
1296 defaults to <option>cgroup-full:rw</option> if the
1297 container retains the CAP_SYS_ADMIN capability,
1298 <option>cgroup-full:mixed</option> otherwise.
1304 If cgroup namespaces are enabled, then any <option>cgroup</option>
1305 auto-mounting request will be ignored, since the container can
1306 mount the filesystems itself, and automounting can confuse the
1310 Note that if automatic mounting of the cgroup filesystem
1311 is enabled, the tmpfs under
1312 <filename>/sys/fs/cgroup</filename> will always be
1313 mounted read-write (but for the <option>:mixed</option>
1314 and <option>:ro</option> cases, the individual
1316 <filename>/sys/fs/cgroup/$hierarchy</filename>, will be
1317 read-only). This is in order to work around a quirk in
1320 <refentrytitle>mountall</refentrytitle>
1321 <manvolnum>8</manvolnum>
1323 command that will cause containers to wait for user
1325 <filename>/sys/fs/cgroup</filename> is mounted read-only
1326 and the container can't remount it read-write due to a
1327 lack of CAP_SYS_ADMIN.
1333 lxc.mount.auto = proc sys cgroup
1334 lxc.mount.auto = proc:rw sys:rw cgroup-full:rw
1343 <title>Root file system</title>
1345 The root file system of the container can be different than that
1351 <option>lxc.rootfs.path</option>
1355 specify the root file system for the container. It can
1356 be an image file, a directory or a block device. If not
1357 specified, the container shares its root file system
1361 For directory or simple block-device backed containers,
1362 a pathname can be used. If the rootfs is backed by a nbd
1363 device, then <filename>nbd:file:1</filename> specifies that
1364 <filename>file</filename> should be attached to a nbd device,
1365 and partition 1 should be mounted as the rootfs.
1366 <filename>nbd:file</filename> specifies that the nbd device
1367 itself should be mounted. <filename>overlayfs:/lower:/upper</filename>
1368 specifies that the rootfs should be an overlay with <filename>/upper</filename>
1369 being mounted read-write over a read-only mount of <filename>/lower</filename>.
1370 For <filename>overlay</filename> multiple <filename>/lower</filename>
1371 directories can be specified. <filename>loop:/file</filename> tells lxc to attach
1372 <filename>/file</filename> to a loop device and mount the loop device.
1379 <option>lxc.rootfs.mount</option>
1383 where to recursively bind <option>lxc.rootfs.path</option>
1384 before pivoting. This is to ensure success of the
1386 <refentrytitle><command>pivot_root</command></refentrytitle>
1387 <manvolnum>8</manvolnum>
1389 syscall. Any directory suffices, the default should
1397 <option>lxc.rootfs.options</option>
1401 extra mount options to use when mounting the rootfs.
1410 <title>Control group</title>
1412 The control group section contains the configuration for the
1413 different subsystem. <command>lxc</command> does not check the
1414 correctness of the subsystem name. This has the disadvantage
1415 of not detecting configuration errors until the container is
1416 started, but has the advantage of permitting any future
1422 <option>lxc.cgroup.[controller name]</option>
1426 Specify the control group value to be set on a legacy cgroup
1427 hierarchy. The controller name is the literal name of the control
1428 group. The permitted names and the syntax of their values is not
1429 dictated by LXC, instead it depends on the features of the Linux
1430 kernel running at the time the container is started, eg.
1431 <option>lxc.cgroup.cpuset.cpus</option>
1437 <option>lxc.cgroup2.[controller name]</option>
1441 Specify the control group value to be set on the unified cgroup
1442 shierarchy. The controller name is the literal name of the control
1443 group. The permitted names and the syntax of their values is not
1444 dictated by LXC, instead it depends on the features of the Linux
1445 kernel running at the time the container is started, eg.
1446 <option>lxc.cgroup2.memory.high</option>
1452 <option>lxc.cgroup.dir</option>
1456 specify a directory or path in which the container's cgroup will
1457 be created. For example, setting
1458 <option>lxc.cgroup.dir = my-cgroup/first</option> for a container
1459 named "c1" will create the container's cgroup as a sub-cgroup of
1460 "my-cgroup". For example, if the user's current cgroup "my-user"
1461 is located in the root cgroup of the cpuset controller in a
1462 cgroup v1 hierarchy this would create the cgroup
1463 "/sys/fs/cgroup/cpuset/my-user/my-cgroup/first/c1" for the
1464 container. Any missing cgroups will be created by LXC. This
1465 presupposes that the user has write access to its current cgroup.
1473 <title>Capabilities</title>
1475 The capabilities can be dropped in the container if this one
1481 <option>lxc.cap.drop</option>
1485 Specify the capability to be dropped in the container. A
1486 single line defining several capabilities with a space
1487 separation is allowed. The format is the lower case of
1488 the capability definition without the "CAP_" prefix,
1489 eg. CAP_SYS_MODULE should be specified as
1492 <refentrytitle><command>capabilities</command></refentrytitle>
1493 <manvolnum>7</manvolnum>
1495 If used with no value, lxc will clear any drop capabilities
1496 specified up to this point.
1502 <option>lxc.cap.keep</option>
1506 Specify the capability to be kept in the container. All other
1507 capabilities will be dropped. When a special value of "none" is
1508 encountered, lxc will clear any keep capabilities specified up
1509 to this point. A value of "none" alone can be used to drop all
1518 <title>Namespaces</title>
1520 A namespace can be cloned (<option>lxc.namespace.clone</option>),
1521 kept (<option>lxc.namespace.keep</option>) or shared
1522 (<option>lxc.namespace.share.[namespace identifier]</option>).
1527 <option>lxc.namespace.clone</option>
1531 Specify namespaces which the container is supposed to be created
1532 with. The namespaces to create are specified as a space separated
1533 list. Each namespace must correspond to one of the standard
1534 namespace identifiers as seen in the
1535 <filename>/proc/PID/ns</filename> directory.
1536 When <option>lxc.namespace.clone</option> is not explicitly set all
1537 namespaces supported by the kernel and the current configuration
1542 To create a new mount, net and ipc namespace set
1543 <option>lxc.namespace.clone=mount net ipc</option>.
1550 <option>lxc.namespace.keep</option>
1554 Specify namespaces which the container is supposed to inherit from
1555 the process that created it. The namespaces to keep are specified as
1556 a space separated list. Each namespace must correspond to one of the
1557 standard namespace identifiers as seen in the
1558 <filename>/proc/PID/ns</filename> directory.
1559 The <option>lxc.namespace.keep</option> is a
1560 blacklist option, i.e. it is useful when enforcing that containers
1561 must keep a specific set of namespaces.
1565 To keep the network, user and ipc namespace set
1566 <option>lxc.namespace.keep=user net ipc</option>.
1570 Note that sharing pid namespaces will likely not work with most init
1575 Note that if the container requests a new user namespace and the
1576 container wants to inherit the network namespace it needs to inherit
1577 the user namespace as well.
1584 <option>lxc.namespace.share.[namespace identifier]</option>
1588 Specify a namespace to inherit from another container or process.
1589 The <option>[namespace identifier]</option> suffix needs to be
1590 replaced with one of the namespaces that appear in the
1591 <filename>/proc/PID/ns</filename> directory.
1595 To inherit the namespace from another process set the
1596 <option>lxc.namespace.share.[namespace identifier]</option> to the PID of
1597 the process, e.g. <option>lxc.namespace.share.net=42</option>.
1601 To inherit the namespace from another container set the
1602 <option>lxc.namespace.share.[namespace identifier]</option> to the name of
1603 the container, e.g. <option>lxc.namespace.share.pid=c3</option>.
1607 To inherit the namespace from another container located in a
1608 different path than the standard liblxc path set the
1609 <option>lxc.namespace.share.[namespace identifier]</option> to the full
1610 path to the container, e.g.
1611 <option>lxc.namespace.share.user=/opt/c3</option>.
1615 In order to inherit namespaces the caller needs to have sufficient
1616 privilege over the process or container.
1620 Note that sharing pid namespaces between system containers will
1621 likely not work with most init systems.
1625 Note that if two processes are in different user namespaces and one
1626 process wants to inherit the other's network namespace it usually
1627 needs to inherit the user namespace as well.
1635 <title>Resource limits</title>
1637 The soft and hard resource limits for the container can be changed.
1638 Unprivileged containers can only lower them. Resources which are not
1639 explicitly specified will be inherited.
1644 <option>lxc.prlimit.[limit name]</option>
1648 Specify the resource limit to be set. A limit is specified as two
1649 colon separated values which are either numeric or the word
1650 'unlimited'. A single value can be used as a shortcut to set both
1651 soft and hard limit to the same value. The permitted names the
1652 "RLIMIT_" resource names in lowercase without the "RLIMIT_"
1653 prefix, eg. RLIMIT_NOFILE should be specified as "nofile". See
1655 <refentrytitle><command>setrlimit</command></refentrytitle>
1656 <manvolnum>2</manvolnum>
1658 If used with no value, lxc will clear the resource limit
1659 specified up to this point. A resource with no explicitly
1660 configured limitation will be inherited from the process starting
1669 <title>Sysctl</title>
1671 Configure kernel parameters for the container.
1676 <option>lxc.sysctl.[kernel parameters name]</option>
1680 Specify the kernel parameters to be set. The parameters available
1681 are those listed under /proc/sys/.
1682 Note that not all sysctls are namespaced. Changing Non-namespaced
1683 sysctls will cause the system-wide setting to be modified.
1685 <refentrytitle><command>sysctl</command></refentrytitle>
1686 <manvolnum>8</manvolnum>
1688 If used with no value, lxc will clear the parameters specified up
1697 <title>Apparmor profile</title>
1699 If lxc was compiled and installed with apparmor support, and the host
1700 system has apparmor enabled, then the apparmor profile under which the
1701 container should be run can be specified in the container
1702 configuration. The default is <command>lxc-container-default-cgns</command>
1703 if the host kernel is cgroup namespace aware, or
1704 <command>lxc-container-default</command> othewise.
1709 <option>lxc.apparmor.profile</option>
1713 Specify the apparmor profile under which the container should
1714 be run. To specify that the container should be unconfined,
1717 <programlisting>lxc.apparmor.profile = unconfined</programlisting>
1719 If the apparmor profile should remain unchanged (i.e. if you
1720 are nesting containers and are already confined), then use
1722 <programlisting>lxc.apparmor.profile = unchanged</programlisting>
1727 <option>lxc.apparmor.allow_incomplete</option>
1731 Apparmor profiles are pathname based. Therefore many file
1732 restrictions require mount restrictions to be effective against
1733 a determined attacker. However, these mount restrictions are not
1734 yet implemented in the upstream kernel. Without the mount
1735 restrictions, the apparmor profiles still protect against accidental
1739 If this flag is 0 (default), then the container will not be
1740 started if the kernel lacks the apparmor mount features, so that a
1741 regression after a kernel upgrade will be detected. To start the
1742 container under partial apparmor protection, set this flag to 1.
1750 <title>SELinux context</title>
1752 If lxc was compiled and installed with SELinux support, and the host
1753 system has SELinux enabled, then the SELinux context under which the
1754 container should be run can be specified in the container
1755 configuration. The default is <command>unconfined_t</command>,
1756 which means that lxc will not attempt to change contexts.
1757 See @DATADIR@/lxc/selinux/lxc.te for an example policy and more
1763 <option>lxc.selinux.context</option>
1767 Specify the SELinux context under which the container should
1768 be run or <command>unconfined_t</command>. For example
1770 <programlisting>lxc.selinux.context = system_u:system_r:lxc_t:s0:c22</programlisting>
1777 <title>Seccomp configuration</title>
1779 A container can be started with a reduced set of available
1780 system calls by loading a seccomp profile at startup. The
1781 seccomp configuration file must begin with a version number
1782 on the first line, a policy type on the second line, followed
1783 by the configuration.
1786 Versions 1 and 2 are currently supported. In version 1, the
1787 policy is a simple whitelist. The second line therefore must
1788 read "whitelist", with the rest of the file containing one (numeric)
1789 sycall number per line. Each syscall number is whitelisted,
1790 while every unlisted number is blacklisted for use in the container
1794 In version 2, the policy may be blacklist or whitelist,
1795 supports per-rule and per-policy default actions, and supports
1796 per-architecture system call resolution from textual names.
1799 An example blacklist policy, in which all system calls are
1800 allowed except for mknod, which will simply do nothing and
1801 return 0 (success), looks like:
1813 <option>lxc.seccomp.profile</option>
1817 Specify a file containing the seccomp configuration to
1818 load before the container starts.
1826 <title>PR_SET_NO_NEW_PRIVS</title>
1828 With PR_SET_NO_NEW_PRIVS active execve() promises not to grant
1829 privileges to do anything that could not have been done without
1830 the execve() call (for example, rendering the set-user-ID and
1831 set-group-ID mode bits, and file capabilities non-functional).
1832 Once set, this bit cannot be unset. The setting of this bit is
1833 inherited by children created by fork() and clone(), and preserved
1835 Note that PR_SET_NO_NEW_PRIVS is applied after the container has
1836 changed into its intended AppArmor profile or SElinux context.
1841 <option>lxc.no_new_privs</option>
1845 Specify whether the PR_SET_NO_NEW_PRIVS flag should be set for the
1846 container. Set to 1 to activate.
1854 <title>UID mappings</title>
1856 A container can be started in a private user namespace with
1857 user and group id mappings. For instance, you can map userid
1858 0 in the container to userid 200000 on the host. The root
1859 user in the container will be privileged in the container,
1860 but unprivileged on the host. Normally a system container
1861 will want a range of ids, so you would map, for instance,
1862 user and group ids 0 through 20,000 in the container to the
1863 ids 200,000 through 220,000.
1868 <option>lxc.idmap</option>
1872 Four values must be provided. First a character, either
1873 'u', or 'g', to specify whether user or group ids are
1874 being mapped. Next is the first userid as seen in the
1875 user namespace of the container. Next is the userid as
1876 seen on the host. Finally, a range indicating the number
1877 of consecutive ids to map.
1885 <title>Container hooks</title>
1887 Container hooks are programs or scripts which can be executed
1888 at various times in a container's lifetime.
1891 When a container hook is executed, additional information is passed
1892 along. The <option>lxc.hook.version</option> argument can be used to
1893 determine if the following arguments are passed as command line
1894 arguments or through environment variables. The arguments are:
1896 <listitem><para> Container name. </para></listitem>
1897 <listitem><para> Section (always 'lxc'). </para></listitem>
1898 <listitem><para> The hook type (i.e. 'clone' or 'pre-mount'). </para></listitem>
1899 <listitem><para> Additional arguments. In the
1900 case of the clone hook, any extra arguments passed will appear as
1901 further arguments to the hook. In the case of the stop hook, paths to
1902 filedescriptors for each of the container's namespaces along with
1903 their types are passed. </para></listitem>
1905 The following environment variables are set:
1907 <listitem><para> LXC_CGNS_AWARE: indicator whether the container is
1908 cgroup namespace aware. </para></listitem>
1909 <listitem><para> LXC_CONFIG_FILE: the path to the container
1910 configuration file. </para></listitem>
1911 <listitem><para> LXC_HOOK_TYPE: the hook type (e.g. 'clone', 'mount',
1912 'pre-mount'). Note that the existence of this environment variable is
1913 conditional on the value of <option>lxc.hook.version</option>. If it
1914 is set to 1 then LXC_HOOK_TYPE will be set.
1916 <listitem><para> LXC_HOOK_SECTION: the section type (e.g. 'lxc',
1917 'net'). Note that the existence of this environment variable is
1918 conditional on the value of <option>lxc.hook.version</option>. If it
1919 is set to 1 then LXC_HOOK_SECTION will be set.
1921 <listitem><para> LXC_HOOK_VERSION: the version of the hooks. This
1922 value is identical to the value of the container's
1923 <option>lxc.hook.version</option> config item. If it is set to 0 then
1924 old-style hooks are used. If it is set to 1 then new-style hooks are
1925 used. </para></listitem>
1926 <listitem><para> LXC_LOG_LEVEL: the container's log level. </para></listitem>
1927 <listitem><para> LXC_NAME: is the container's name. </para></listitem>
1928 <listitem><para> LXC_[NAMESPACE IDENTIFIER]_NS: path under
1929 /proc/PID/fd/ to a file descriptor referring to the container's
1930 namespace. For each preserved namespace type there will be a separate
1931 environment variable. These environment variables will only be set if
1932 <option>lxc.hook.version</option> is set to 1. </para></listitem>
1933 <listitem><para> LXC_ROOTFS_MOUNT: the path to the mounted root filesystem. </para></listitem>
1934 <listitem><para> LXC_ROOTFS_PATH: this is the lxc.rootfs.path entry
1935 for the container. Note this is likely not where the mounted rootfs is
1936 to be found, use LXC_ROOTFS_MOUNT for that. </para></listitem>
1937 <listitem><para> LXC_SRC_NAME: in the case of the clone hook, this is
1938 the original container's name. </para></listitem>
1942 Standard output from the hooks is logged at debug level.
1943 Standard error is not logged, but can be captured by the
1944 hook redirecting its standard error to standard output.
1949 <option>lxc.hook.version</option>
1953 To pass the arguments in new style via environment variables set to
1954 1 otherwise set to 0 to pass them as arguments.
1955 This setting affects all hooks arguments that were traditionally
1956 passed as arguments to the script. Specifically, it affects the
1957 container name, section (e.g. 'lxc', 'net') and hook type (e.g.
1958 'clone', 'mount', 'pre-mount') arguments. If new-style hooks are
1959 used then the arguments will be available as environment variables.
1960 The container name will be set in LXC_NAME. (This is set
1961 independently of the value used for this config item.) The section
1962 will be set in LXC_HOOK_SECTION and the hook type will be set in
1964 It also affects how the paths to file descriptors referring to the
1965 container's namespaces are passed. If set to 1 then for each
1966 namespace a separate environment variable LXC_[NAMESPACE
1967 IDENTIFIER]_NS will be set. If set to 0 then the paths will be
1968 passed as arguments to the stop hook.
1976 <option>lxc.hook.pre-start</option>
1980 A hook to be run in the host's namespace before the
1981 container ttys, consoles, or mounts are up.
1989 <option>lxc.hook.pre-mount</option>
1993 A hook to be run in the container's fs namespace but before
1994 the rootfs has been set up. This allows for manipulation
1995 of the rootfs, i.e. to mount an encrypted filesystem. Mounts
1996 done in this hook will not be reflected on the host (apart from
1997 mounts propagation), so they will be automatically cleaned up
1998 when the container shuts down.
2006 <option>lxc.hook.mount</option>
2010 A hook to be run in the container's namespace after
2011 mounting has been done, but before the pivot_root.
2019 <option>lxc.hook.autodev</option>
2023 A hook to be run in the container's namespace after
2024 mounting has been done and after any mount hooks have
2025 run, but before the pivot_root, if
2026 <option>lxc.autodev</option> == 1.
2027 The purpose of this hook is to assist in populating the
2028 /dev directory of the container when using the autodev
2029 option for systemd based containers. The container's /dev
2030 directory is relative to the
2031 ${<option>LXC_ROOTFS_MOUNT</option>} environment
2032 variable available when the hook is run.
2040 <option>lxc.hook.start-host</option>
2044 A hook to be run in the host's namespace after the
2045 container has been setup, and immediately before starting
2054 <option>lxc.hook.start</option>
2058 A hook to be run in the container's namespace immediately
2059 before executing the container's init. This requires the
2060 program to be available in the container.
2068 <option>lxc.hook.stop</option>
2072 A hook to be run in the host's namespace with references
2073 to the container's namespaces after the container has been shut
2074 down. For each namespace an extra argument is passed to the hook
2075 containing the namespace's type and a filename that can be used to
2076 obtain a file descriptor to the corresponding namespace, separated
2077 by a colon. The type is the name as it would appear in the
2078 <filename>/proc/PID/ns</filename> directory.
2079 For instance for the mount namespace the argument usually looks
2080 like <filename>mnt:/proc/PID/fd/12</filename>.
2088 <option>lxc.hook.post-stop</option>
2092 A hook to be run in the host's namespace after the
2093 container has been shut down.
2101 <option>lxc.hook.clone</option>
2105 A hook to be run when the container is cloned to a new one.
2106 See <citerefentry><refentrytitle><command>lxc-clone</command></refentrytitle>
2107 <manvolnum>1</manvolnum></citerefentry> for more information.
2115 <option>lxc.hook.destroy</option>
2119 A hook to be run when the container is destroyed.
2127 <title>Container hooks Environment Variables</title>
2129 A number of environment variables are made available to the startup
2130 hooks to provide configuration information and assist in the
2131 functioning of the hooks. Not all variables are valid in all
2132 contexts. In particular, all paths are relative to the host system
2133 and, as such, not valid during the <option>lxc.hook.start</option> hook.
2138 <option>LXC_NAME</option>
2142 The LXC name of the container. Useful for logging messages
2143 in common log environments. [<option>-n</option>]
2151 <option>LXC_CONFIG_FILE</option>
2155 Host relative path to the container configuration file. This
2156 gives the container to reference the original, top level,
2157 configuration file for the container in order to locate any
2158 additional configuration information not otherwise made
2159 available. [<option>-f</option>]
2167 <option>LXC_CONSOLE</option>
2171 The path to the console output of the container if not NULL.
2172 [<option>-c</option>] [<option>lxc.console.path</option>]
2180 <option>LXC_CONSOLE_LOGPATH</option>
2184 The path to the console log output of the container if not NULL.
2185 [<option>-L</option>]
2193 <option>LXC_ROOTFS_MOUNT</option>
2197 The mount location to which the container is initially bound.
2198 This will be the host relative path to the container rootfs
2199 for the container instance being started and is where changes
2200 should be made for that instance.
2201 [<option>lxc.rootfs.mount</option>]
2209 <option>LXC_ROOTFS_PATH</option>
2213 The host relative path to the container root which has been
2214 mounted to the rootfs.mount location.
2215 [<option>lxc.rootfs.path</option>]
2223 <option>LXC_SRC_NAME</option>
2227 Only for the clone hook. Is set to the original container name.
2235 <option>LXC_TARGET</option>
2239 Only for the stop hook. Is set to "stop" for a container
2240 shutdown or "reboot" for a container reboot.
2248 <option>LXC_CGNS_AWARE</option>
2252 If unset, then this version of lxc is not aware of cgroup
2253 namespaces. If set, it will be set to 1, and lxc is aware
2254 of cgroup namespaces. Note this does not guarantee that
2255 cgroup namespaces are enabled in the kernel. This is used
2256 by the lxcfs mount hook.
2263 <title>Logging</title>
2265 Logging can be configured on a per-container basis. By default,
2266 depending upon how the lxc package was compiled, container startup
2267 is logged only at the ERROR level, and logged to a file named after
2268 the container (with '.log' appended) either under the container path,
2272 Both the default log level and the log file can be specified in the
2273 container configuration file, overriding the default behavior. Note
2274 that the configuration file entries can in turn be overridden by the
2275 command line options to <command>lxc-start</command>.
2280 <option>lxc.log.level</option>
2284 The level at which to log. The log level is an integer in
2285 the range of 0..8 inclusive, where a lower number means more
2286 verbose debugging. In particular 0 = trace, 1 = debug, 2 =
2287 info, 3 = notice, 4 = warn, 5 = error, 6 = critical, 7 =
2288 alert, and 8 = fatal. If unspecified, the level defaults
2289 to 5 (error), so that only errors and above are logged.
2292 Note that when a script (such as either a hook script or a
2293 network interface up or down script) is called, the script's
2294 standard output is logged at level 1, debug.
2300 <option>lxc.log.file</option>
2304 The file to which logging info should be written.
2310 <option>lxc.log.syslog</option>
2314 Send logging info to syslog. It respects the log level defined in
2315 <command>lxc.log.level</command>. The argument should be the syslog
2316 facility to use, valid ones are: daemon, local0, local1, local2,
2317 local3, local4, local5, local5, local6, local7.
2325 <title>Autostart</title>
2327 The autostart options support marking which containers should be
2328 auto-started and in what order. These options may be used by LXC tools
2329 directly or by external tooling provided by the distributions.
2335 <option>lxc.start.auto</option>
2339 Whether the container should be auto-started.
2340 Valid values are 0 (off) and 1 (on).
2346 <option>lxc.start.delay</option>
2350 How long to wait (in seconds) after the container is
2351 started before starting the next one.
2357 <option>lxc.start.order</option>
2361 An integer used to sort the containers when auto-starting
2362 a series of containers at once.
2368 <option>lxc.monitor.unshare</option>
2372 If not zero the mount namespace will be unshared from the host
2373 before initializing the container (before running any pre-start
2374 hooks). This requires the CAP_SYS_ADMIN capability at startup.
2381 <option>lxc.group</option>
2385 A multi-value key (can be used multiple times) to put the
2386 container in a container group. Those groups can then be
2387 used (amongst other things) to start a series of related
2396 <title>Autostart and System Boot</title>
2398 Each container can be part of any number of groups or no group at all.
2399 Two groups are special. One is the NULL group, i.e. the container does
2400 not belong to any group. The other group is the "onboot" group.
2404 When the system boots with the LXC service enabled, it will first
2405 attempt to boot any containers with lxc.start.auto == 1 that is a member
2406 of the "onboot" group. The startup will be in order of lxc.start.order.
2407 If an lxc.start.delay has been specified, that delay will be honored
2408 before attempting to start the next container to give the current
2409 container time to begin initialization and reduce overloading the host
2410 system. After starting the members of the "onboot" group, the LXC system
2411 will proceed to boot containers with lxc.start.auto == 1 which are not
2412 members of any group (the NULL group) and proceed as with the onboot
2419 <title>Container Environment</title>
2421 If you want to pass environment variables into the container (that
2422 is, environment variables which will be available to init and all of
2423 its descendents), you can use <command>lxc.environment</command>
2424 parameters to do so. Be careful that you do not pass in anything
2425 sensitive; any process in the container which doesn't have its
2426 environment scrubbed will have these variables available to it, and
2427 environment variables are always available via
2428 <command>/proc/PID/environ</command>.
2432 This configuration parameter can be specified multiple times; once
2433 for each environment variable you wish to configure.
2439 <option>lxc.environment</option>
2443 Specify an environment variable to pass into the container.
2447 lxc.environment = APP_ENV=production
2448 lxc.environment = SYSLOG_SERVER=192.0.2.42
2451 It is possible to inherit host environment variables by setting the
2452 name of the variable without a "=" sign. For example:
2455 lxc.environment = PATH
2465 <title>Examples</title>
2467 In addition to the few examples given below, you will find
2468 some other examples of configuration file in @DOCDIR@/examples
2471 <title>Network</title>
2472 <para>This configuration sets up a container to use a veth pair
2473 device with one side plugged to a bridge br0 (which has been
2474 configured before on the system by the administrator). The
2475 virtual network device visible in the container is renamed to
2478 lxc.uts.name = myhostname
2479 lxc.net.0.type = veth
2480 lxc.net.0.flags = up
2481 lxc.net.0.link = br0
2482 lxc.net.0.name = eth0
2483 lxc.net.0.hwaddr = 4a:49:43:49:79:bf
2484 lxc.net.0.ipv4.address = 10.2.3.5/24 10.2.3.255
2485 lxc.net.0.ipv6.address = 2003:db8:1:0:214:1234:fe0b:3597
2490 <title>UID/GID mapping</title>
2491 <para>This configuration will map both user and group ids in the
2492 range 0-9999 in the container to the ids 100000-109999 on the host.
2495 lxc.idmap = u 0 100000 10000
2496 lxc.idmap = g 0 100000 10000
2501 <title>Control group</title>
2502 <para>This configuration will setup several control groups for
2503 the application, cpuset.cpus restricts usage of the defined cpu,
2504 cpus.share prioritize the control group, devices.allow makes
2505 usable the specified devices.</para>
2507 lxc.cgroup.cpuset.cpus = 0,1
2508 lxc.cgroup.cpu.shares = 1234
2509 lxc.cgroup.devices.deny = a
2510 lxc.cgroup.devices.allow = c 1:3 rw
2511 lxc.cgroup.devices.allow = b 8:0 rw
2516 <title>Complex configuration</title>
2517 <para>This example show a complex configuration making a complex
2518 network stack, using the control groups, setting a new hostname,
2519 mounting some locations and a changing root file system.</para>
2521 lxc.uts.name = complex
2522 lxc.net.0.type = veth
2523 lxc.net.0.flags = up
2524 lxc.net.0.link = br0
2525 lxc.net.0.hwaddr = 4a:49:43:49:79:bf
2526 lxc.net.0.ipv4.address = 10.2.3.5/24 10.2.3.255
2527 lxc.net.0.ipv6.address = 2003:db8:1:0:214:1234:fe0b:3597
2528 lxc.net.0.ipv6.address = 2003:db8:1:0:214:5432:feab:3588
2529 lxc.net.1.type = macvlan
2530 lxc.net.1.flags = up
2531 lxc.net.1.link = eth0
2532 lxc.net.1.hwaddr = 4a:49:43:49:79:bd
2533 lxc.net.1.ipv4.address = 10.2.3.4/24
2534 lxc.net.1.ipv4.address = 192.168.10.125/24
2535 lxc.net.1.ipv6.address = 2003:db8:1:0:214:1234:fe0b:3596
2536 lxc.net.2.type = phys
2537 lxc.net.2.flags = up
2538 lxc.net.2.link = dummy0
2539 lxc.net.2.hwaddr = 4a:49:43:49:79:ff
2540 lxc.net.2.ipv4.address = 10.2.3.6/24
2541 lxc.net.2.ipv6.address = 2003:db8:1:0:214:1234:fe0b:3297
2542 lxc.cgroup.cpuset.cpus = 0,1
2543 lxc.cgroup.cpu.shares = 1234
2544 lxc.cgroup.devices.deny = a
2545 lxc.cgroup.devices.allow = c 1:3 rw
2546 lxc.cgroup.devices.allow = b 8:0 rw
2547 lxc.mount.fstab = /etc/fstab.complex
2548 lxc.mount.entry = /lib /root/myrootfs/lib none ro,bind 0 0
2549 lxc.rootfs.path = dir:/mnt/rootfs.complex
2550 lxc.cap.drop = sys_module mknod setuid net_raw
2551 lxc.cap.drop = mac_override
2558 <title>See Also</title>
2561 <refentrytitle><command>chroot</command></refentrytitle>
2562 <manvolnum>1</manvolnum>
2566 <refentrytitle><command>pivot_root</command></refentrytitle>
2567 <manvolnum>8</manvolnum>
2571 <refentrytitle><filename>fstab</filename></refentrytitle>
2572 <manvolnum>5</manvolnum>
2576 <refentrytitle><filename>capabilities</filename></refentrytitle>
2577 <manvolnum>7</manvolnum>
2585 <title>Author</title>
2586 <para>Daniel Lezcano <email>daniel.lezcano@free.fr</email></para>
2591 <!-- Keep this comment at the end of the file
2596 sgml-minimize-attributes:nil
2597 sgml-always-quote-attributes:t
2600 sgml-parent-document:nil
2601 sgml-default-dtd-file:nil
2602 sgml-exposed-tags:nil
2603 sgml-local-catalogs:nil
2604 sgml-local-ecat-files:nil