Mount problem LXC 3.0.3

(norrarvid) #1

I am trying to mount the java directory into an unprivileged LXC container on Ubuntu 18.04. This worked fine in Ubuntu 17.10 but I have no success in Ubuntu 18.04.
The container needs a bridge network device. That initially did not worked, but after I installed 3.0.3 from it worked.
(dpkg -i liblxc1_3.0.3-0ubuntu1~18.04.1_amd64.deb liblxc-common_3.0.3-0ubuntu1~18.04.1_amd64.deb lxc_3.0.3-0ubuntu1~18.04.1_all.deb lxcfs_3.0.3-0ubuntu1~18.04.1_amd64.deb lxc-utils_3.0.3-0ubuntu1~18.04.1_amd64.deb)

When I add:
lxc.mount.entry = /usr/lib/jvm/java-8-openjdk-amd64 opt/java none defaults,bind,relative,create=dir 0 0
I get an error:
ubuntu:~$ lxc-start -n centos2 -F -o out.tmp -l=TRACE
lxc-start: centos2: utils.c: safe_mount: 1179 No such file or directory - Failed to mount “/usr/lib/x86_64-linux-gnu/lxc//usr/lib/jvm/java-8-openjdk-amd64” onto “/usr/lib/x86_64-linux-gnu/lxc/opt/java”
lxc-start: centos2: conf.c: mount_entry: 2019 No such file or directory - Failed to mount “/usr/lib/x86_64-linux-gnu/lxc//usr/lib/jvm/java-8-openjdk-amd64” on “/usr/lib/x86_64-linux-gnu/lxc/opt/java”
lxc-start: centos2: conf.c: lxc_setup: 3611 Failed to setup mount entries
lxc-start: centos2: start.c: do_start: 1263 Failed to setup container “centos2” lxc-start: centos2: sync.c: __sync_wait: 62 An error occurred in another process (expected sequence number 5)
lxc-start: centos2: start.c: __lxc_start: 1939 Failed to spawn container “centos2” lxc-start: centos2: tools/lxc_start.c: main: 330 The container failed to start

I can see that the /opt/java directory is successfully created inside the containers rootfs.
I got the same error even when I rename java-8-openjdk-amd64, so the path does not exist when I try to start the container.
lxc.mount.entry = /usr/lib/jvm/java-8-openjdk-amd64_none opt/java none defaults,bind,relative,create=dir 0 0

Do I have to change any file permissions, ACL:s or AppArmor preferences to make it work or are my lxc.mount.entry configuration wrong?

(Stéphane Graber) #2

@brauner can you take a look at this?

(Christian Brauner) #3

Please show the config file.
I can’t reproduce this.
For some reason lxc seems to prepend the mount point for the rootfs to the path:


and that’s very odd.

(norrarvid) #4

Thank you!
Here are the config files. ( comments removed) All lxc.include files are not changed, but I include them to show the entire configuration.
The rootfs is created from : lxc-create -t download -n centos2

cat .local/share/lxc/centos2/config
lxc.include = /usr/share/lxc/config/common.conf
lxc.include = /usr/share/lxc/config/userns.conf
lxc.arch = x86_64
lxc.include = /etc/lxc/default.conf
lxc.idmap = u 0 231072 65536
lxc.idmap = g 0 231072 65536
lxc.rootfs.path = dir:/home/testing/.local/share/lxc/centos2/rootfs = centos2 = veth = up = brtcp
lxc.mount.entry = /usr/lib/jvm/java-8-openjdk-amd64 opt/java none defaults,bind,relative,create=dir 0 0

cat /etc/lxc/default.conf = veth = lxcbr0 = up = 00:16:3e:xx:xx:xx

cat /usr/share/lxc/config/common.conf
lxc.tty.dir = lxc
lxc.pty.max = 1024
lxc.tty.max = 4
lxc.cap.drop = mac_admin mac_override sys_time sys_module sys_rawio
lxc.hook.clone = /usr/share/lxc/hooks/clonehostname
lxc.cgroup.devices.deny = a
lxc.cgroup.devices.allow = c : m
lxc.cgroup.devices.allow = b : m
lxc.cgroup.devices.allow = c 1:3 rwm
lxc.cgroup.devices.allow = c 1:5 rwm
lxc.cgroup.devices.allow = c 1:7 rwm
lxc.cgroup.devices.allow = c 5:0 rwm
lxc.cgroup.devices.allow = c 5:1 rwm
lxc.cgroup.devices.allow = c 5:2 rwm
lxc.cgroup.devices.allow = c 1:8 rwm
lxc.cgroup.devices.allow = c 1:9 rwm
lxc.cgroup.devices.allow = c 136:* rwm
lxc.cgroup.devices.allow = c 10:229 rwm = cgroup:mixed proc:mixed sys:mixed
lxc.mount.entry = /sys/fs/fuse/connections sys/fs/fuse/connections none bind,optional 0 0
lxc.seccomp.profile = /usr/share/lxc/config/common.seccomp
lxc.include = /usr/share/lxc/config/common.conf.d/

cat /usr/share/lxc/config/common.conf.d/00-lxcfs.conf
lxc.hook.mount = /usr/share/lxcfs/lxc.mount.hook = /usr/share/lxcfs/lxc.reboot.hook

cat /usr/share/lxc/config/common.seccomp
reject_force_umount # comment this to allow umount -f; not recommended
kexec_load errno 1
open_by_handle_at errno 1
init_module errno 1
finit_module errno 1
delete_module errno 1

cat /usr/share/lxc/config/userns.conf
lxc.cgroup.devices.deny =
lxc.cgroup.devices.allow =
lxc.cap.drop =
lxc.cap.keep =
lxc.tty.dir = = sys:rw

(Mrinal Dhillon) #5

Please remove relative option in mount entry

(norrarvid) #6

Thank you very much!

I can confirm that if a remove ’relative’ from the mount line everything works as expected.

Old line:

lxc.mount.entry = /usr/lib/jvm/java-8-openjdk-amd64 opt/java none defaults,bind,relative,create=dir 0 0

Updated line:

lxc.mount.entry = /usr/lib/jvm/java-8-openjdk-amd64 opt/java none defaults,bind,create=dir 0 0