Skip to content

Commit ec2ad55

Browse files
committed
lxc: Edit for flow.
1 parent 7fe0814 commit ec2ad55

File tree

1 file changed

+37
-33
lines changed

1 file changed

+37
-33
lines changed

src/config/lxc.md

Lines changed: 37 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -19,32 +19,36 @@ configuration; simply use the various `lxc-*` commands, such as
1919

2020
### Creating unprivileged containers
2121

22-
Unprivileged containers enhance security by mapping normal the normal range
23-
(0--65535) of user IDs (UIDs) and group IDs (GIDs) inside each container to
24-
ranges not in use by the host system. The host ranges must be *subordinated* to
25-
the user who will be running the unprivileged containers. The
22+
The normal ranges of user IDs (UIDs) and group IDs (GIDs) are from 0 to 65535.
23+
Unprivileged containers enhance security by mapping UID and GID ranges inside
24+
each container to ranges not in use by the host system. The host ranges must be
25+
*subordinated* to the user who will be running the unprivileged containers.
26+
27+
Subordinate UIDs and GIDs are assigned by the
2628
[subuid(5)](https://man.voidlinux.org/subuid.5) and
27-
[subgid(5)](https://man.voidlinux.org/subgid.5) files respectively assign
28-
subordinate UIDs and GIDs. The superuser may launch unprivileged containers in
29-
the system store; regular users may launch unprivileged containers in their
30-
individual stores.
29+
[subgid(5)](https://man.voidlinux.org/subgid.5) files, respectively. The
30+
superuser may launch unprivileged containers in the system store; regular users
31+
may launch unprivileged containers in their individual stores.
3132

32-
To create unprivileged containers, first edit `/etc/subuid` and `/etc/subgid`
33-
to delegate ranges. For example:
33+
To create unprivileged containers, first edit `/etc/subuid` and `/etc/subgid` to
34+
delegate ranges. For example:
3435

3536
```
3637
root:1000000:65536
3738
user:2000000:65536
3839
```
3940

40-
In colon-deliminated each entry, the first field is the user to which a
41-
subordinate range will be assigned, the second field is the smallest numeric ID
42-
defining a subordinate range, and the third field is the number of consecutive
43-
IDs in the range. Generally, the number of consecutive IDs should be an integer
44-
multiple of 65536; the starting value is not important, except to ensure that
45-
the various ranges defined in the file do not overlap. In this example, `root`
46-
controls UIDs (or, from `subgid`, GIDs) ranging from 1000000 to 1065535,
47-
inclusive; `user` controls IDs ranging from 2000000 to 20655535.
41+
In each colon-delimited entry:
42+
43+
- the first field is the user to which a subordinate range will be assigned;
44+
- the second field is the smallest numeric ID defining a subordinate range; and
45+
- the third field is the number of consecutive IDs in the range.
46+
47+
Generally, the number of consecutive IDs should be an integer multiple of 65536;
48+
the starting value is not important, except to ensure that the various ranges
49+
defined in the file do not overlap. In this example, `root` controls UIDs (or,
50+
from `subgid`, GIDs) ranging from 1000000 to 1065535, inclusive; `user` controls
51+
IDs ranging from 2000000 to 2065535.
4852

4953
Before creating a container, the user owning the container will need a
5054
`default.conf` file specifying the subuid and subgid range to use. For
@@ -60,14 +64,14 @@ lxc.idmap = g 0 1000000 65536
6064
The isolated `u` character indicates a UID mapping, while the isolated `g`
6165
indicates a GID mapping. The first numeric value should generally always be 0;
6266
this indicates the start of the UID or GID range *as seen from within the
63-
container*. The second numeric value is the start of the corresponding range
64-
*as seen from outside the container*, and may be an arbitrary value within the
65-
range delegated in `/etc/subuid` or `/etc/subgid`. The final value is the numer
66-
of consecutive IDs to map.
67+
container*. The second numeric value is the start of the corresponding range *as
68+
seen from outside the container*, and may be an arbitrary value within the range
69+
delegated in `/etc/subuid` or `/etc/subgid`. The final value is the number of
70+
consecutive IDs to map.
6771

6872
**Note:** Although the external range start is arbitrary, care must be taken to
69-
ensure that the end of the range implied by the start and number does not
70-
extend beyond the range of IDs delegated to the user.
73+
ensure that the end of the range implied by the start and number does not extend
74+
beyond the range of IDs delegated to the user.
7175

7276
If configuring a non-root user, edit `/etc/lxc/lxc-usernet` as root to specify a
7377
network device quota. For example, to allow the user named `user` to create up
@@ -79,25 +83,25 @@ user veth lxcbr0 10
7983

8084
The user can now create and use unprivileged containers with the `lxc-*`
8185
utilities. To create a simple Void container named `mycontainer`, use a command
82-
similar to
86+
similar to:
8387

8488
```
8589
lxc-create -n mycontainer -t download -- \
8690
--dist voidlinux --release current --arch x86_64
8791
```
8892

8993
You may substitute another architecture for `x86_64`, and you may specify a
90-
`musl` image by adding `--variant musl` to the end of the the command. See the
94+
`musl` image by adding `--variant musl` to the end of the command. See the
9195
[LXC Image Server](http://images.linuxcontainers.org) for a list of available
9296
containers.
9397

94-
All containers will share the same subordinate UID and GID maps by default.
95-
This is permissible, but it means that an attacker who gains elevated access
96-
within one container and can somehow break out of the container will have
97-
similar access to other containers. To isolate containers from each other,
98-
alter the `lxc.idmap` ranges in `default.conf` to point to a unique range
99-
*before* you create each container. Trying to fix permissions on a container
100-
created with the wrong map is possible, but inconvenient.
98+
All containers will share the same subordinate UID and GID maps by default. This
99+
is permissible, but it means that an attacker who gains elevated access within
100+
one container, and can somehow break out of that container, will have similar
101+
access to other containers. To isolate containers from each other, alter the
102+
`lxc.idmap` ranges in `default.conf` to point to a unique range *before* you
103+
create each container. Trying to fix permissions on a container created with the
104+
wrong map is possible, but inconvenient.
101105

102106
## LXD
103107

0 commit comments

Comments
 (0)