Container Basics On Linux (Namespaces/Cgroups)
Peer into a process mount namespace without breaking your brain
đź§© The Challenge
You’re trying to figure out why a containerized app can’t find a config file, but from the host, the path looks perfectly fine. It’s maddening because you’re looking at the host filesystem while the container is living in its own little world.
đź’ˇ The Fix
Use the nsenter command to hop directly into the mount namespace of the containerized process. It basically gives you a shell inside the container’s environment without needing to mess with Docker exec or inspect everything manually.
nsenter -t <pid> -m /bin/bash
⚙️ Why It Works
By targeting the PID of the main application process and specifying the mount namespace flag, you are effectively shifting your shell’s view to see exactly what that specific process sees on the filesystem. This bypasses all the layers of abstraction that usually make troubleshooting a nightmare.
🚀 Pro-Tip: Keep that PID handy by piping your ps aux output through grep first, or you’ll be running around in circles.
Linux Tips & Tricks | © ngelinux.com | 9/26/2026
