On Tue, Jan 30, 2018 at 10:19:12PM +0530, Shailendra Rana wrote:
> Hi,
> 
> Is there a way we can get the PID/GID/UID of a container process using
> the host  PID/GID/UID of that container process ? Basically mapping of
> host PID/GID/UID to container PID/GID/UID.
> 
> Thanks,
> Shailendra

It's technically doable, yes, but not particularly enjoyable :)

stgraber@castiana:~$ ls -lh /proc/ | grep 8261
dr-xr-xr-x  9          1000000          1000000    0 Jan 30 15:33 8261
stgraber@castiana:~$ cat /proc/8261/status | grep -i ns
NStgid: 8261    1
NSpid:  8261    1
NSpgid: 8261    1
NSsid:  8261    1
stgraber@castiana:~$ cat /proc/8261/uid_map 
         0    1000000 1000000000
stgraber@castiana:~$ cat /proc/8261/gid_map 
         0    1000000 1000000000


In this case, host PID 8261 is PID 1 in the container as can be found in
the status file. For the owner, you need to read the uid and gid map,
then do the math.

In this case, the map says that uid 0 in the container is uid 1000000 on
the host. The gid map is the same, so that means that this process is
running as uid=0 gid=0 in the container.

-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com

Attachment: signature.asc
Description: PGP signature

_______________________________________________
lxc-users mailing list
[email protected]
http://lists.linuxcontainers.org/listinfo/lxc-users

Reply via email to