nsenter(1)
Run a program in a namespace context by entering the namespaces of another process.
Synopsis
nsenter [OPTION]... [PROG [ARGS]...]Description
nsenter enters one or more namespaces of an existing process and then executes a program. This is useful for inspecting and interacting with containers, as each container typically has its own set of namespaces (network, PID, IPC, mount, UTS, user).
Common uses include debugging running containers, accessing container filesystems, or running commands within an existing container's namespace context without needing to exec through the container runtime.
Common options
| Flag | What it does |
|---|---|
-t PID | Enter namespaces of the specified process (most common usage) |
-n, --net | Enter the network namespace |
-p, --pid | Enter the PID (process) namespace |
-m, --mount | Enter the mount namespace |
-i, --ipc | Enter the IPC namespace |
-u, --uts | Enter the UTS namespace (hostname/domainname) |
-U, --user | Enter the user namespace |
-a, --all | Enter all available namespaces |
--root=PATH | Set the root directory for the new process |
--wd=PATH | Set the working directory for the new process |
Examples
Enter all namespaces of process 1234 and start a bash shell
nsenter -t 1234 /bin/bashView network interfaces from process 1234's network namespace
nsenter -t 1234 -n ip addrList the root directory as seen from process 1234's mount namespace
nsenter -t 1234 -m ls /View network connections inside a running Docker container
docker inspect -f '{{.State.Pid}}' mycontainer | xargs -I {} nsenter -t {} -n netstat -anList processes visible from process 1234's PID namespace
nsenter -t 1234 -p ps auxShow IPC resources from process 1234's IPC namespace
nsenter -t 1234 -i ipcs