Several evenings, I already try to get an LXC installation working with user-space containers. Since it's going to be a new server, I don't care (yet) too much about distribution and release, so I tried Debian 7+8 and Ubuntu 14.04 and 15.04 as host and Ubuntu 15.04 and Debian 8 as guest. All of them have their problems. The summary:
Debian 7.8: lxc-create: This command has to be run as root (both guests)
Debian 8.0: lxc-create: Operation not permitted (both guests)
Ubuntu 14.04 w/ Ubuntu 15.04 guest: lxc-start: call to cgmanager_create_sync failed: invalid request / The container failed to start.
Ubuntu 14.04 w/ Debian 8 guest: lxc-create: ERROR: Couldn't find a matching image.
Ubuntu 15.04: lxc-start: call to cgmanager_move_pid_sync failed: invalid request / The container failed to start. (both guests)
I followed the tutorial https://help.ubuntu.com/lts/serverguide/lxc.html and https://linuxcontainers.org/lxc/getting-started/, and they don't look like it's so complicated.
I wrote a script to make the test reproducable (to be run as root on a freshly booted live cd). Can anyone tell me what's wrong with it?
#!/bin/sh
# need to be run as root
set -x
echo "==== SYSTEM INFO & INSTALL ===="
lsb_release -a
uname -a
apt-get update
apt-get install -y lxc
apt-get clean
lxc-checkconfig
ifconfig
brctl show
adduser testuser
cat /etc/subuid /etc/subgid
cat >/etc/lxc/lxc-usernet <<.e
# USERNAME TYPE BRIDGE COUNT
testuser veth lxcbr0 2
.e
sudo -u testuser -i mkdir -p .config/lxc
sudo -u testuser -i tee .config/lxc/default.conf <<.e
lxc.id_map = u 0 $(grep testuser /etc/subuid | cut -d: -f2) 65536
lxc.id_map = g 0 $(grep testuser /etc/subgid | cut -d: -f2) 65536
lxc.network.type = veth
lxc.network.link = lxcbr0
lxc.network.flags = up
lxc.network.hwaddr = 00:16:3e:xx:xx:xx
.e
cat /home/testuser/.config/lxc/default.conf
echo "==== TEST UBUNTU VIVID GUEST ===="
sudo -u testuser -i lxc-create -t download -n vivid1 -- -d ubuntu -r utopic -a amd64
#You just created an Ubuntu container (release=trusty, arch=amd64, variant=default)
#sudo -u testuser -i lxc-start -n vivid1 -d
#read press_enter_key_when_quit
if [ $? -eq 0 ]; then
rm /tmp/log
sudo -u testuser -i lxc-start -n vivid1 -l debug --logfile /tmp/log
cat /tmp/log
fi
echo "==== TEST DEBIAN JESSIE GUEST ===="
sudo -u testuser -i lxc-create -t download -n jessie1 -- -d debian -r jessie -a amd64
#You just created an Ubuntu container (release=trusty, arch=amd64, variant=default)
#sudo -u testuser -i lxc-start -n jessie1 -d
#read press_enter_key_when_quit
if [ $? -eq 0 ]; then
rm /tmp/log
sudo -u testuser -i lxc-start -n jessie1 -l debug --logfile /tmp/log
cat /tmp/log
fi
echo "==== END OF SCRIPT ===="
On pastebin, I posted the console output from all these machines:
- Test with debian-live-7.8.0-amd64-xfce-desktop.iso
- Test with debian-live-8.0.0-amd64-xfce-desktop.iso
- Test with xubuntu-14.04.2-desktop-amd64.iso
- Test with xubuntu-15.04-desktop-amd64.iso
Update
I tried further with Ubuntu 15.04 as host. I found the bug report https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1413927 Which has a similar but not same problem. But journalctl revealed problems with cgmanager:
May 20 16:06:10 xubuntu cgmanager[4736]: cgmanager:do_create_main: pid 17417 (uid 1000 gid 1000) may not create under /run/cgmanager/fs/blkio/user.slice/user-999.slice/session-c1.scope
May 20 16:06:10 xubuntu cgmanager[4736]: cgmanager:do_create_main: pid 17417 (uid 1000 gid 1000) may not create under /run/cgmanager/fs/cpu/user.slice/user-999.slice/session-c1.scope
May 20 16:06:10 xubuntu cgmanager[4736]: cgmanager:do_create_main: pid 17417 (uid 1000 gid 1000) may not create under /run/cgmanager/fs/cpuset/user.slice/user-999.slice/session-c1.scope
May 20 16:06:10 xubuntu cgmanager[4736]: cgmanager:do_create_main: pid 17417 (uid 1000 gid 1000) may not create under /run/cgmanager/fs/devices/user.slice/user-999.slice/session-c1.scope
May 20 16:06:10 xubuntu cgmanager[4736]: cgmanager:do_create_main: pid 17417 (uid 1000 gid 1000) may not create under /run/cgmanager/fs/freezer/user.slice/user-999.slice/session-c1.scope
May 20 16:06:10 xubuntu cgmanager[4736]: cgmanager:do_create_main: pid 17417 (uid 1000 gid 1000) may not create under /run/cgmanager/fs/hugetlb/user.slice/user-999.slice/session-c1.scope
May 20 16:06:10 xubuntu cgmanager[4736]: cgmanager:do_create_main: pid 17417 (uid 1000 gid 1000) may not create under /run/cgmanager/fs/memory/user.slice/user-999.slice/session-c1.scope
May 20 16:06:10 xubuntu cgmanager[4736]: cgmanager:do_create_main: pid 17417 (uid 1000 gid 1000) may not create under /run/cgmanager/fs/net_cls/user.slice/user-999.slice/session-c1.scope
May 20 16:06:10 xubuntu cgmanager[4736]: cgmanager:do_create_main: pid 17417 (uid 1000 gid 1000) may not create under /run/cgmanager/fs/perf_event/user.slice/user-999.slice/session-c1.scope
May 20 16:06:10 xubuntu cgmanager[4736]: cgmanager:do_create_main: pid 17417 (uid 1000 gid 1000) may not create under /run/cgmanager/fs/none,name=systemd/user.slice/user-999.slice/session-c1.scope
May 20 16:06:10 xubuntu cgmanager[4736]: cgmanager: Invalid path /run/cgmanager/fs/blkio/user.slice/user-999.slice/session-c1.scope/lxc/jessie1
May 20 16:06:10 xubuntu cgmanager[4736]: cgmanager:per_ctrl_move_pid_main: Invalid path /run/cgmanager/fs/blkio/user.slice/user-999.slice/session-c1.scope/lxc/jessie1
May 20 16:06:10 xubuntu cgmanager[4736]: cgmanager: Invalid path /run/cgmanager/fs/cpu/user.slice/user-999.slice/session-c1.scope/lxc/jessie1
May 20 16:06:10 xubuntu cgmanager[4736]: cgmanager:per_ctrl_move_pid_main: Invalid path /run/cgmanager/fs/cpu/user.slice/user-999.slice/session-c1.scope/lxc/jessie1
May 20 16:06:10 xubuntu cgmanager[4736]: cgmanager: Invalid path /run/cgmanager/fs/cpuset/user.slice/user-999.slice/session-c1.scope/lxc/jessie1
May 20 16:06:10 xubuntu cgmanager[4736]: cgmanager:per_ctrl_move_pid_main: Invalid path /run/cgmanager/fs/cpuset/user.slice/user-999.slice/session-c1.scope/lxc/jessie1
May 20 16:06:10 xubuntu cgmanager[4736]: cgmanager: Invalid path /run/cgmanager/fs/devices/user.slice/user-999.slice/session-c1.scope/lxc/jessie1
May 20 16:06:10 xubuntu cgmanager[4736]: cgmanager:per_ctrl_move_pid_main: Invalid path /run/cgmanager/fs/devices/user.slice/user-999.slice/session-c1.scope/lxc/jessie1
May 20 16:06:10 xubuntu cgmanager[4736]: cgmanager: Invalid path /run/cgmanager/fs/freezer/user.slice/user-999.slice/session-c1.scope/lxc/jessie1
May 20 16:06:10 xubuntu cgmanager[4736]: cgmanager:per_ctrl_move_pid_main: Invalid path /run/cgmanager/fs/freezer/user.slice/user-999.slice/session-c1.scope/lxc/jessie1
May 20 16:06:10 xubuntu cgmanager[4736]: cgmanager: Invalid path /run/cgmanager/fs/hugetlb/user.slice/user-999.slice/session-c1.scope/lxc/jessie1
May 20 16:06:10 xubuntu cgmanager[4736]: cgmanager:per_ctrl_move_pid_main: Invalid path /run/cgmanager/fs/hugetlb/user.slice/user-999.slice/session-c1.scope/lxc/jessie1
May 20 16:06:10 xubuntu cgmanager[4736]: cgmanager: Invalid path /run/cgmanager/fs/memory/user.slice/user-999.slice/session-c1.scope/lxc/jessie1
May 20 16:06:10 xubuntu cgmanager[4736]: cgmanager:per_ctrl_move_pid_main: Invalid path /run/cgmanager/fs/memory/user.slice/user-999.slice/session-c1.scope/lxc/jessie1
May 20 16:06:10 xubuntu cgmanager[4736]: cgmanager: Invalid path /run/cgmanager/fs/net_cls/user.slice/user-999.slice/session-c1.scope/lxc/jessie1
May 20 16:06:10 xubuntu cgmanager[4736]: cgmanager:per_ctrl_move_pid_main: Invalid path /run/cgmanager/fs/net_cls/user.slice/user-999.slice/session-c1.scope/lxc/jessie1
May 20 16:06:10 xubuntu cgmanager[4736]: cgmanager: Invalid path /run/cgmanager/fs/perf_event/user.slice/user-999.slice/session-c1.scope/lxc/jessie1
May 20 16:06:10 xubuntu cgmanager[4736]: cgmanager:per_ctrl_move_pid_main: Invalid path /run/cgmanager/fs/perf_event/user.slice/user-999.slice/session-c1.scope/lxc/jessie1
May 20 16:06:10 xubuntu cgmanager[4736]: cgmanager: Invalid path /run/cgmanager/fs/none,name=systemd/user.slice/user-999.slice/session-c1.scope/lxc/jessie1
May 20 16:06:10 xubuntu cgmanager[4736]: cgmanager:per_ctrl_move_pid_main: Invalid path /run/cgmanager/fs/none,name=systemd/user.slice/user-999.slice/session-c1.scope/lxc/jessie1
Update 2
I tried more: I installed Ubuntu trusty and vivid on two virtual machines and installed all updates on them. Then I tested both once with the original lxc package and once with the ones from the lxc daily ppa. Result is always the same error as shown above.