Setting up LXC 3.x to run unprivileged containers.
As you:
1) Download the source for lxc-3.0.3.tar.gz and lxcfs-3.0.3.tar.gz.
2) Untar lxc-3.0.3 and lxcfs-3.0.3
3) cd lxc-3.0.3
4) ./configure --prefix=/usr --sysconfdir=/etc --libdir=/usr/lib64 --localstatedir=/var --mandir=/usr/man --docdir=/usr/doc/lxc-3.0.3 --infodir=/usr/info --infodir=/usr/info --with-global-conf=/etc/lxc/lxc.conf --with-rootfs-path=/var/lib/rootfs-lxc
5) make -j8
6) cd ../lxcfs-3.0.3
7) ./configure --prefix=/usr --sysconfdir=/etc --libdir=/usr/lib64 --localstatedir=/var --mandir=/usr/man --docdir=/usr/doc/lxcfs-3.0.3 --infodir=/usr/info --with-rootfs-path=/var/lib/rootfs-lxc
8) make -j8
9) Create the file $HOME/.config/lxc/default.conf with the following contents:
Code:
lxc.idmap = u 0 131072 65536
lxc.idmap = g 0 131072 65536
lxc.mount.auto = cgroup
lxc.net.0.type = veth
lxc.net.0.link = lxcbr0
lxc.net.0.name = eth0
lxc.net.0.flags = up
lxc.net.0.hwaddr = 00:16:3e:xx:xx:xx
lxc.environment = PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin
lxc.environment = HOME=/root
lxc.environment = USER=root
As root:
10) removepkg lxc-2.0.9
11) cd lxc-3.0.3
12) make install
13) cd ../lxcfs-3.0.3
14) make install
15) Create the file /etc/subuid with the following contents:
Code:
root:65536:65536
<your uid>:131072:65536
Replace <your uid> with your user ID.
16) Create the file /etc/subgid with the following contents:
Code:
root:65536:65536
<your gid>:131072:65536
Replace <your gid> with your group ID.
17) mount -t cgroup -o rw,noexec,nosuid,nodev,none,name=systemd systemd /sys/fs/cgroup/systemd
18) cgcreate -g name=systemd:lxc -g *:lxc -a <your uid>:<your gid> -t <your uid>:<your gid>
Replace <your uid> and <your gid> with your user ID and your group ID, respectively.
19) /usr/libexec/lxc/lxc-net start
20) lxcfs -s -o allow_other /var/lib/lxcfs/ &
21) modprobe autofs4
As you:
22) cgexec -g *:lxc bash
23) Create a Debian container:
lxc-create -t download -n debian -- -d debian -r stretch -a amd64
24) Start the container:
lxc-start debian
25) Attach to the container:
lxc-attach debian
You should now be able to run 'apt install' to install packages.