Stop guessing which namespace your container is hiding in

Container Basics On Linux (Namespaces/Cgroups)

Stop guessing which namespace your container is hiding in

🧩 The Challenge

Trying to troubleshoot a process inside a container only to realize you are looking at the host’s network stack is a special kind of migraine. I’ve wasted way too much time running ip addr only to see a bunch of interfaces that clearly didn’t belong to the application I was debugging.

💡 The Fix

Use lsns to list the namespaces and then nsenter to jump directly into the process’s view of the world. It saves you from guessing if you’re actually inside the container’s environment or just looking at the host shell.

lsns -p <PID>
nsenter -t <PID> -n ip addr

⚙️ Why It Works

The lsns command maps out the namespace IDs for a specific PID, and nsenter effectively swaps your current shell’s namespace to match the target, putting you inside the container’s network or mount context instantly.

🚀 Pro-Tip: Alias nsenter to ns for when you need to jump into a container namespace in a hurry.

Linux Tips & Tricks | © ngelinux.com | 8/30/2026

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Newest
Oldest Most Voted