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 https://www.ubuntuupdates.org/package/core/bionic/universe/proposed/lxc 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?