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