Requirement : To create an unprivilaged container WITHOUT its own root file system so that i can make host’s directory as containers rootfile sytem
Below are the steps i have followed
created a user with useradd command on the host
/etc/subuid has
testuser:231072:65536
/etc/subgid has
testuser:231072:65536
I logged in with the “testuser” login
created a container(unprivilaged) with( my container name is appA, and config file name is config)
lxc-create -n appA -t none -f config -P /var/lib/lxc
config file looks like this,
lxc.idmap = u 0 231072 1002
lxc.idmap = g 0 231072 1003
lxc.idmap = u 1002 1002 1
lxc.idmap = g 1003 1003 1
lxc idmap = u 1004 232075 64533
lxc.idmap = g 1005 232076 64532
lxc.console.path = none
lxc.mount.entry = /usr/bin/appfw /var/lib/lxc/appA/shared none ro,bind,0 0
container creation is succesful. I get an error if i change lxc.mount.entry
to
lxc.mount.entry = /usr/bin/appfw shared none ro,bind,0 0
I checked the logs but log says mounted “/usr/bin/appfw” on “/var/lib/lxc/appA/shared” with filesystem type none
, but I am not able to list /usr/bin/appfw inside /var/lib/lxc/appA/shared.
I have executed chmod 777 on /usr/bin/appfw
Note:
Tried with the below config file also
lxc.idmap = u 0 231072 65536
lxc.idmap = g 0 231072 65536
lxc.console.path = none
lxc.mount.entry = /usr/bin/appfw /var/lib/lxc/appA/shared none ro,bind,0 0
Please let me know if i am going wrong anywhere.
Environment details
Working on Ubuntu 18.04 distribution
lxc-checkconfig shows “enabled” for each option
Should be correct. What’s the startup failure you’re getting?
Note that when successful, you won’t see this mounted from the host, you’ll need to go check from within the container with lxc-attach.
Thank you for the hint. I didnt know that we need to check the shared folder after attaching to container. i was just checking it in thr RFS of container.
I also wanted to know why
lxc.mount.auto = proc:mixed sys
is the mandatory command in config file for get mount working.
What is the significance of proc:mixed sys. i only got lxc.mount working with
lxc.mount.entry = /usr/bin/appfw /var/lib/lxc/appA/shared none ro,bind,0
lxc.mount.auto = proc:mixed sys
Still have Mount error with below command in config file
lxc.mount.entry = /usr/bin/appfw shared none ro,bind,0 0
lxc.mount.auto is used to setup /proc and /sys in your container.
You don’t have to use it, but if you don’t, then you’d need lxc.mount.entry entries for /proc and /sys or LXC will likely run into problems.
So the logic should actually be and has been for a long time that absolute target paths are ignored and relative paths accepted so this is strange. What’s your LXC version?