[Lxc-users] mapping host PID <-> container PID

Serge Hallyn serge.hallyn at canonical.com
Thu Apr 28 14:41:27 UTC 2011


Quoting Ulli Horlacher (framstag at rus.uni-stuttgart.de):
> 
> Is there a way to get the corresponding host PID for a container PID?
> 
> For example: inside the the container the process "init" has always PID 1.
> But what PID has this process in the host process table?
> 
> ps aux | grep ... is not what I am looking for, I want more robust solution.

There is nothing that gives you a 100% guaranteed correct race-free
correspondence right now.  You can look under /proc/<pid>/root/proc/ to
see the pids valid in the container, and you can relate output of
lxc-ps --forest to ps --forest output.  But nothing under /proc that I
know of tells you "this task is the same as that task".  You can't
even look at /proc/<pid> inode numbers since they are different
filesystems for each proc mount.

It's tempting to say that we should put a per-task unique id under
/proc/<pid> for each task.  However that would likely be nacked because
it introduces a new namespace of its own.

-serge




More information about the lxc-users mailing list