]> git.proxmox.com Git - mirror_lxc.git/blame - README.md
conf: cleanup macros lxc_mount_auto_mounts
[mirror_lxc.git] / README.md
CommitLineData
ea033bbc 1[![LXD](https://linuxcontainers.org/static/img/containers.png)](https://linuxcontainers.org/lxd)
dc46727f
CB
2# LXC
3
dc46727f
CB
4LXC is the well-known and heavily tested low-level Linux container runtime. It
5is in active development since 2008 and has proven itself in critical
6production environments world-wide. Some of its core contributors are the same
7people that helped to implement various well-known containerization features
8inside the Linux kernel.
9
ea033bbc
CB
10## Status
11Type | Service | Status
12--- | --- | ---
13CI (Linux) | Jenkins | [![Build Status](https://jenkins.linuxcontainers.org/job/lxc-github-commit/badge/icon)](https://jenkins.linuxcontainers.org/job/lxc-github-commit/)
14CI (Linux) | Travis | [![Build Status](https://travis-ci.org/lxc/lxc.svg?branch=master)](https://travis-ci.org/lxc/lxc/)
15Project status | CII Best Practices | [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/1087/badge)](https://bestpractices.coreinfrastructure.org/projects/1087)
a62cf72a 16Code Quality | LGTM | [![Language grade: C/C++](https://img.shields.io/lgtm/grade/cpp/g/lxc/lxc.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/lxc/lxc/context:cpp)
0577a33d 17Static Analysis | Coverity | <a href="https://scan.coverity.com/projects/lxc-linux-containers"> <img alt="Coverity Scan Build Status" src="https://img.shields.io/coverity/scan/369.svg"/> </a>
ea033bbc 18
dc46727f
CB
19## System Containers
20
21LXC's main focus is system containers. That is, containers which offer an
22environment as close as possible as the one you'd get from a VM but without the
23overhead that comes with running a separate kernel and simulating all the
24hardware.
25
26This is achieved through a combination of kernel security features such as
27namespaces, mandatory access control and control groups.
28
29## Unprivileged Containers
30
31Unprivileged containers are containers that are run without any privilege. This
32requires support for user namespaces in the kernel that the container is run
33on. LXC was the first runtime to support unprivileged containers after user
34namespaces were merged into the mainline kernel.
35
36In essence, user namespaces isolate given sets of UIDs and GIDs. This is
37achieved by establishing a mapping between a range of UIDs and GIDs on the host
38to a different (unprivileged) range of UIDs and GIDs in the container. The
39kernel will translate this mapping in such a way that inside the container all
40UIDs and GIDs appear as you would expect from the host whereas on the host
41these UIDs and GIDs are in fact unprivileged. For example, a process running as
42UID and GID 0 inside the container might appear as UID and GID 100000 on the
43host. The implementation and working details can be gathered from the
44corresponding user namespace man page.
45
46Since unprivileged containers are a security enhancement they naturally come
47with a few restrictions enforced by the kernel. In order to provide a fully
48functional unprivileged container LXC interacts with 3 pieces of setuid code:
49
50- lxc-user-nic (setuid helper to create a veth pair and bridge it on the host)
51- newuidmap (from the shadow package, sets up a uid map)
52- newgidmap (from the shadow package, sets up a gid map)
53
54Everything else is run as your own user or as a uid which your user owns.
55
56In general, LXC's goal is to make use of every security feature available in
57the kernel. This means LXC's configuration management will allow experienced
58users to intricately tune LXC to their needs.
59
60A more detailed introduction into LXC security can be found under the following link
61
62- https://linuxcontainers.org/lxc/security/
63
64### Removing all Privilege
65
66In principle LXC can be run without any of these tools provided the correct
67configuration is applied. However, the usefulness of such containers is usually
68quite restricted. Just to highlight the two most common problems:
69
701. Network: Without relying on a setuid helper to setup appropriate network
71 devices for an unprivileged user (see LXC's `lxc-user-nic` binary) the only
72 option is to share the network namespace with the host. Although this should
73 be secure in principle, sharing the host's network namespace is still one
74 step of isolation less and increases the attack vector.
75 Furthermore, when host and container share the same network namespace the
76 kernel will refuse any sysfs mounts. This usually means that the init binary
77 inside of the container will not be able to boot up correctly.
78
792. User Namespaces: As outlined above, user namespaces are a big security
ac8f64dc
CB
80 enhancement. However, without relying on privileged helpers users who are
81 unprivileged on the host are only permitted to map their own UID into
82 a container. A standard POSIX system however, requires 65536 UIDs and GIDs
83 to be available to guarantee full functionality.
dc46727f
CB
84
85## Configuration
86
87LXC is configured via a simple set of keys. For example,
88
7a96a068 89- `lxc.rootfs.path`
dc46727f
CB
90- `lxc.mount.entry`
91
92LXC namespaces configuration keys by using single dots. This means complex
7fa3f2e9 93configuration keys such as `lxc.net.0` expose various subkeys such as
2e44ae28
CB
94`lxc.net.0.type`, `lxc.net.0.link`, `lxc.net.0.ipv6.address`, and others for
95even more fine-grained configuration.
dc46727f
CB
96
97LXC is used as the default runtime for [LXD](https://github.com/lxc/lxd),
98a container hypervisor exposing a well-designed and stable REST-api on top of
99it.
100
101## Kernel Requirements
102
103LXC runs on any kernel from 2.6.32 onwards. All it requires is a functional
104C compiler. LXC works on all architectures that provide the necessary kernel
105features. This includes (but isn't limited to):
106
107- i686
108- x86_64
109- ppc, ppc64, ppc64le
110- s390x
111- armvl7, arm64
112
113LXC also supports at least the following C standard libraries:
114
115- glibc
116- musl
117- bionic (Android's libc)
118
119## Backwards Compatibility
120
121LXC has always focused on strong backwards compatibility. In fact, the API
122hasn't been broken from release `1.0.0` onwards. Main LXC is currently at
123version `2.*.*`.
124
125## Reporting Security Issues
126
127The LXC project has a good reputation in handling security issues quickly and
128efficiently. If you think you've found a potential security issue, please
129report it by e-mail to all of the following persons:
130
a3cf04da 131- serge (at) hallyn (dot) com
dc46727f
CB
132- stgraber (at) ubuntu (dot) com
133- christian.brauner (at) ubuntu (dot) com
134
135For further details please have a look at
136
137- https://linuxcontainers.org/lxc/security/
138
139## Becoming Active in LXC development
140
141We always welcome new contributors and are happy to provide guidance when
142necessary. LXC follows the kernel coding conventions. This means we only
143require that each commit includes a `Signed-off-by` line. The coding style we
144use is identical to the one used by the Linux kernel. You can find a detailed
145introduction at:
146
147- https://www.kernel.org/doc/html/v4.10/process/coding-style.html
148
149and should also take a look at the [CONTRIBUTING](CONTRIBUTING) file in this
150repo.
151
152If you want to become more active it is usually also a good idea to show up in
153the LXC IRC channel `#lxc-dev` on `Freenode`. We try to do all development out
154in the open and discussion of new features or bugs is done either in
154f6474 155appropriate GitHub issues or on IRC.
dc46727f
CB
156
157When thinking about making security critical contributions or substantial
158changes it is usually a good idea to ping the developers first and ask whether
159a PR would be accepted.
160
161## Semantic Versioning
162
163LXC and its related projects strictly adhere to a [semantic
164versioning](http://semver.org/) scheme.
165
166## Downloading the current source code
167
168Source for the latest released version can always be downloaded from
169
170- https://linuxcontainers.org/downloads/
171
172You can browse the up to the minute source code and change history online
173
174- https://github.com/lxc/lxc
175
176## Building LXC
177
178Without considering distribution specific details a simple
179
180 ./autogen.sh && ./configure && make && sudo make install
181
182is usually sufficient.
183
184In order to test current git master of LXC it is usually a good idea to compile with
185
186 ./autogen.sh && ./configure && make
187
188in a convenient directory and set `LD_LIBRARY_PATH="${BUILD_DIR}"/lxc/src/lxc/.libs`.
189
190## Getting help
191
192When you find you need help, the LXC projects provides you with several options.
193
194### Discuss Forum
195
196We maintain an discuss forum at
197
198- https://discuss.linuxcontainers.org/
199
200where you can get support.
201
202### IRC
203
204You can find support by joining `#lxcontainers` on `Freenode`.
205
206### Mailing Lists
207
208You can check out one of the two LXC mailing list archives and register if
209interested:
210
211- http://lists.linuxcontainers.org/listinfo/lxc-devel
212- http://lists.linuxcontainers.org/listinfo/lxc-users