760 B
760 B
Identifying a Process's Cgroup by PID
Read /proc/<PID>/cgroup to find which cgroup (and therefore which container) a process belongs to.
/proc/PID/cgroup
cat /proc/<PID>/cgroup
Shows all cgroup controllers the process belongs to:
12:blkio:/user.slice
11:memory:/user.slice/user-1000.slice
...
0::/user.slice/user-1000.slice/session-1.scope
On cgroup v2, the path after :: is the cgroup path under /sys/fs/cgroup/.
Other Methods
# ps format options
ps -o pid,cgroup -p <PID>
# systemd systems
systemd-cgls --unit <unit-name>
systemd-cgls # whole tree
Quick One-Liners
cat /proc/self/cgroup # current shell
cat /proc/$$/cgroup # also current shell
cat /proc/1234/cgroup # specific PID