I am configuring my LXD containers to run unpriviledged as root.
How can I check that they indeed run as such?
Is it enough that ps -ef
on the host shows that all processes running in containers follow the template
165536 5284 1104 0 12:19 ? 00:00:00 /usr/sbin/sshd -D
(the first element is a uid)
or is there a lxc
parameter which shows the "priviledge level" of a container?
yes, is enough that you see that your UID is different than root and other users in your host for the processes running in your container. (setuid/setgid mapping magic)
The page you linked to describes lxc not lxd. lxd is essentially a daemon process that provides access to lxc's features, in a higher-level/more-convenient way. I believe the answer for lxd is:
If that shows "true", then the container is privileged, else not.
Per stgraber's post you can also query the set of privileged containers by running:
It's also possible to check if a container is unprivileged from inside the LXD container by checking:
/proc/self/uid_map
/proc/self/gid_map
where it will show something like (root
0
mapped to user1000000
):(assuming
/etc/subuid
&/etc/subgid
are correctly configured on the container host)These values can be read by
root
or an unprivileged user.