Container Basics On Linux (Namespaces/Cgroups)
See what your container is actually hiding from the host
š§© The Challenge
You ever try to kill a zombie process inside a container from the host and get āNo such processā even though you can see it in your container logs? Itās because the PID you see on the host is just the kernelās way of dealing with namespaces, and itās a total headache when you are trying to debug cross-namespace visibility.
š” The Fix
Use the nsenter utility to enter the specific namespaces of a container process so you can run commands as if you were sitting inside that containerās sandbox. It clears up all the confusion about what files and processes are actually reachable.
nsenter --target $(docker inspect --format '{{.State.Pid}}' <container_name>) --mount --uts --ipc --net --pid
āļø Why It Works
By explicitly switching your shell into the target processās namespace, you effectively bypass the hostās restricted view. You are essentially tricking your tools into thinking they belong inside the container environment you are currently fighting with.
š Pro-Tip: Alias this to āenter-containerā with a positional argument for the nameāyou will thank yourself at 3 AM.
Linux Tips & Tricks | Ā© ngelinux.com | 10/18/2026
