Container Basics On Linux (Namespaces/Cgroups)
Peek into a container process namespaces without losing your mind
đź§© The Challenge
Trying to figure out what a container is actually seeing on the host is usually a nightmare of `docker inspect` dumps or just guessing. I’ve wasted way too many hours staring at process lists trying to figure out why a pod thinks it has a different network view than the host.
đź’ˇ The Fix
Use the nsenter command to hop into the same namespaces as a running process so you can see exactly what the container sees. It’s like being a ghost inside the container’s shell.
nsenter -t <pid> -n ip addr
nsenter -t <pid> -m ls /
⚙️ Why It Works
By pointing at a process ID and specifying flags for network or mount namespaces, the kernel drops your shell right into that specific sandbox environment. It bypasses all the abstraction layers and lets you run host-side tools inside the container’s view.
🚀 Pro-Tip: Always grab the PID from the host perspective, not the container’s internal view, or nsenter will just point you at thin air.
Linux Tips & Tricks | © ngelinux.com | 10/22/2026
