Container Basics On Linux (Namespaces/Cgroups)
Stop guessing why your process cant see the network
š§© The Challenge
You are trying to debug a container that acts like it has zero network connectivity, but you are staring at a perfectly valid interface inside the shell. It is infuriating when you realize you are looking at the hostās perspective, not the containerās isolated world.
š” The Fix
Use nsenter to drop your shell directly into the target processās network namespace. It saves you from having to hop through layers of container runtimes just to run a single ping or tcpdump.
nsenter -t <PID> -n ip addr show
āļø Why It Works
By targeting the PID of the containerās main process, this command forces your shell to use the network namespace allocated to that specific unit. Everything you run afterward thinks it is inside the container, ignoring the hostās actual network state.
š Pro-Tip: Alias this to something like ānenter-netā because you will definitely forget the flags next time.
Linux Tips & Tricks | Ā© ngelinux.com | 11/6/2026
