Site icon New Generation Enterprise Linux

See exactly where your container is hiding its process IDs

Container Basics On Linux (Namespaces/Cgroups)

See exactly where your container is hiding its process IDs

🧩 The Challenge

You are digging through a container on a host and the PID you see inside isn’t the one shown by ps on the host. It drives me up the wall trying to map them when a service acts up.

💡 The Fix

Use the unshare tool or look directly at the proc file system to reconcile the container process ID with your host-level view. It stops the guessing game when you need to kill a stuck process.

readlink /proc/$(pgrep -f "your_container_app")/ns/pid

⚙️ Why It Works

Accessing the ns directory under proc shows you the unique identifier for the namespace; if the ID matches what you see inside the container, you know you are looking at the same process environment.

🚀 Pro-Tip: Pipe that into ls -l to see all the namespaces for a process at once, including network and mount points.

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

0 0 votes
Article Rating
Exit mobile version