Container Basics On Linux (Namespaces/Cgroups)
Peek inside a containers namespace without losing your sanity
đź§© The Challenge
You’re staring at a container that refuses to connect to a service, and you’re convinced the routing table inside is completely borked. Trying to debug network namespaces from the host usually leads to a headache, especially when you can’t just install iproute2 into a production distroless image.
đź’ˇ The Fix
Use nsenter to drop yourself right into the process’s environment so you can run network tools as if you were sitting inside the container. It’s way faster than guessing what’s going on from the outside.
nsenter -t <PID> -n ip addr show
⚙️ Why It Works
This command maps your terminal session to the network namespace of the specified PID, effectively bypassing the container’s lack of diagnostic tools. Once you’re in there, you get a clear view of exactly what that process sees on its own interfaces.
🚀 Pro-Tip: Use -m, -u, or -p flags with the same command to hop into the mount, UTS, or PID namespaces if you need to check environment variables or file permissions.
Linux Tips & Tricks | © ngelinux.com | 9/24/2026
