Stop watching your container processes leak into the host shell

Container Basics On Linux (Namespaces/Cgroups)

Stop watching your container processes leak into the host shell

🧩 The Challenge

You ever run a handful of Docker containers and suddenly your ps aux output looks like a crime scene? It is annoying as hell when you are trying to find a rogue process on the host and have to filter through fifty lines of container junk you do not care about right now.

💡 The Fix

Use the unshare utility to quickly check what your process tree looks like without all the noise from the rest of the system. It lets you jump into a custom PID namespace temporarily so you can see things from the perspective of a specific container or isolate a process entirely.

sudo unshare --fork --pid --mount-proc ps aux

⚙️ Why It Works

This command creates a brand new PID namespace and remounts /proc so that the ps command only reports processes existing within that isolated bubble. By stripping away the host view, you get a clean look at exactly what is happening inside that restricted context.

🚀 Pro-Tip: Add –mount-proc to any unshare command involving PID namespaces or ps will just lie to you and show the host processes anyway.

Linux Tips & Tricks | © ngelinux.com | 11/25/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted