Container Basics On Linux (Namespaces/Cgroups)
Peer into the abyss of your container namespaces
š§© The Challenge
Trying to figure out why a process inside a container canāt talk to a socket on the host is a nightmare when youāre just guessing from the outside. Iāve spent way too many nights squinting at ps aux lists trying to map whatās actually running where.
š” The Fix
Use nsenter to step right into the containerās shoes and run commands as if you were living inside that processās environment. It saves you from installing debugging tools inside every single production image.
nsenter -t <pid> -n ip addr
nsenter -t <pid> -m -u -i -n -p ps aux
āļø Why It Works
By grabbing the PID of the target process, nsenter effectively switches your current shell into that containerās specific namespaces, letting you see the networking and process tree exactly how the container sees them. It bypasses the need for bloated container entrypoints just to run a quick trace.
š Pro-Tip: Alias this as āenterpidā in your bashrc and save your sanity.
Linux Tips & Tricks | Ā© ngelinux.com | 11/15/2026
