Hello linuxcontainers,
i try to setup a development host on Debian bullseye/arm64 (stable) with lxc 4.0.6-2. Host and guests are all the same OS. I already run lxc on another machine but not nested.
+---------------------------------------------+
| Physical host (Raspberry pi4) |
+---------------------------------------------+
| |
| +-----------------------------------------+ |
| | Ansible | |
| +-----------------------------------------+ |
| | uid 10000000 10000000 root | |
| | gid 10000000 10000000 root | |
| | | |
| | +--------+ +---------+ +----------+ | |
| | |dev-db | |dev-www | |dev-mail | | |
| | +--------+ +---------+ +----------+ | |
| | |u 100000| |u 200000 | |u 300000 | | |
| | | 65536 | | 65536 | | 65536 | | |
| | | | | | | | | |
| | |g 100000| |g 200000 | |g 300000 | | |
| | | 65536 | | 65536 | | 65536 | | |
| | +--------+ +---------+ +----------+ | |
| +-----------------------------------------+ |
+---------------------------------------------+
Host
# Template used to create this container: /usr/share/lxc/templates/lxc-download
# Parameters passed to the template:
# For additional config options, please look at lxc.container.conf(5)
# Uncomment the following line to support nesting containers:
#lxc.include = /usr/share/lxc/config/nesting.conf
# (Be aware this has security implications)
# Distribution configuration
lxc.include = /usr/share/lxc/config/common.conf
lxc.include = /usr/share/lxc/config/userns.conf
lxc.arch = linux64
# Container specific configuration
lxc.apparmor.profile = generated
lxc.apparmor.allow_nesting = 1
lxc.idmap = u 0 10000000 10000000
lxc.idmap = g 0 10000000 10000000
lxc.rootfs.path = dir:/var/lib/lxc/ansible/rootfs
lxc.uts.name = ansible
# enable apparmor inside this contrainer
lxc.mount.entry = /sys/kernel/security sys/kernel/security none bind,optional 0 0
lxc.mount.entry = /mnt/btrfs/lxcsub var/lib/lxc none bind,optional 0 0
# Network configuration
lxc.net.0.type = veth
lxc.net.0.link = br0
lxc.net.0.flags = up
lxc.net.0.hwaddr = 02:FF:BB:00:00:01
# autostart
lxc.start.auto = 1
The nested containers look like this:
root@ansible:/# cat /var/lib/lxc/dev-db/config
# Template used to create this container: /usr/share/lxc/templates/lxc-download
# Parameters passed to the template: --arch arm64 --dist debian --release bullseye
# For additional config options, please look at lxc.container.conf(5)
# Uncomment the following line to support nesting containers:
#lxc.include = /usr/share/lxc/config/nesting.conf
# (Be aware this has security implications)
# enable apparmor inside this contrainer
# Distribution configuration
lxc.include = /usr/share/lxc/config/common.conf
lxc.include = /usr/share/lxc/config/userns.conf
lxc.arch = linux64
# Container specific configuration
lxc.apparmor.profile = generated
lxc.apparmor.allow_nesting = 1
lxc.idmap = u 0 100000 65536
lxc.idmap = g 0 100000 65536
lxc.mount.entry = /sys/kernel/security sys/kernel/security none bind,optional 0 0
lxc.rootfs.path = dir:/var/lib/lxc/dev-db/rootfs
lxc.uts.name = dev-db
# Network configuration
lxc.net.0.type = veth
lxc.net.0.link = lxcbr0
lxc.net.0.flags = up
lxc.net.0.hwaddr = 02:FF:AA:00:10:01
In htop i can see the “stacked” uids of the processes like expected. In the “ansible” container i can see them runnign with lxc-ls --fancy
but a lxc-attach -n dev-db
fails with
root@ansible:/# lxc-attach -n dev-db
lxc-attach: dev-db: conf.c: userns_exec_minimal: 4242 Permission denied - Running parent function failed
I also tried the lxc-unpriv-start
and lxc-unpriv-attach
commands but they also fail with that error message.
Important software components:
systemd on all host/containers: 247.3-7+deb11u1
kernel: Debian 5.18.16-1~bpo11+1 (2022-08-12) aarch64 GNU/Linux
Oh …
sudo sysctl kernel.unprivileged_userns_clone
kernel.unprivileged_userns_clone = 1
So: What could be the issue that this second attach fails?
EDIT: I also uncommented
lxc.include = /usr/share/lxc/config/nesting.conf
on all configs but it didnt work…
EDIT2:
georg@rpi4-rt:~$ sudo lxc-attach -n ansible
root@ansible:/# lxc-attach -n dev-db
lxc-attach: dev-db: conf.c: userns_exec_minimal: 4242 Permission denied - Running parent function failed
root@dev-server:/#
This is the way i tried this.