Container Basics On Linux (Namespaces/Cgroups)
Stop the invisible wall between your host and container processes
đ§© The Challenge
Youâve likely tried to poke at a process inside a container from your host, only to have ps show you absolutely nothing. Itâs annoying as hell when you know the app is running but the kernel acts like itâs invisible to your standard monitoring tools.
đĄ The Fix
Use nsenter to step into the containerâs PID namespace so you can see the world from the perspective of the application. It saves you from having to install debugging tools inside your minimal container images.
PID=$(docker inspect --format {{.State.Pid}} <container_name_or_id>)
nsenter -t $PID -p -m ps aux
âïž Why It Works
By telling nsenter which PID namespace to join, you effectively break out of your hostâs isolated view and inherit the process tree of the target container. And since youâre passing the -m flag too, you get to see their mount namespace, which makes inspecting local config files way easier.
đ Pro-Tip: Alias this to something like ânpsâ because youâll definitely be doing it more than once this week.
Linux Tips & Tricks | © ngelinux.com | 8/27/2026
