Peek at who is actually hiding inside a PID namespace
Container Basics On Linux (Namespaces/Cgroups)
Peek at who is actually hiding inside a PID namespace
🧩 The Challenge
You’re staring at a process list inside a container and see a bunch of random PIDs, but you have no clue what that process thinks its real process ID is on the host. I’ve spent way too much time doing mental math trying to trace a misbehaving child process back to the host kernel.
💡 The Fix
Just peek into the proc filesystem directly to see the mapping of the namespace. It saves you from guessing which host PID corresponds to that weird 123 inside your container.
ls -l /proc/<pid>/ns/pid
readlink /proc/<pid>/ns/pid
⚙️ Why It Works
Every process carries a set of symlinks in /proc that point to its namespace inodes. Comparing these IDs across the host and container lets you confirm they are physically isolated without any black magic.
🚀 Pro-Tip: If the inodes match, you aren’t actually in a separate namespace.
Linux Tips & Tricks | © ngelinux.com | 9/20/2026
