Use it to understand container isolation or to enter a container's view for troubleshooting.
Linux Namespaces
Linux namespaces isolate what a process sees: pid, net, mnt, uts, ipc, user and cgroup namespaces. Containers combine them so each container has its own processes, network, filesystem and hostname.
1. Host PID of the container: docker inspect -f '{{.State.Pid}}' <c> / crictl inspect.
2. lsns -p <pid> — namespaces.
3. Enter: nsenter -t <pid> -n ip a.
4. Shared host namespaces? check spec (hostNetwork/hostPID).
5. Avoid unless required.
process → set of namespaces → isolated views
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 How to verify Verify boundary
Get the host PID with docker inspect -f {{.State.Pid}} <name> or crictl inspect. Run lsns -p <pid> to list its namespaces. Use nsenter -t <pid> -n -m to run host tools inside the container namespaces without installing them in the image.
Step 2 Common failures Narrow the fault
Running with --network host, --pid host or --privileged removes isolation that users often assume is there. Debug tools may show host data if they run outside the container namespaces. User namespace remapping changes file ownership on bind mounts, which shows up as permission denied.
nsenter -t <pid> -n runs host tools inside a container's network namespace. User namespaces map container root to an unprivileged host user (rootless). Sharing host namespaces (--network host, hostPID) removes isolation.
lsns -p <pid>— namespaces of a processnsenter -t <pid> -n <cmd>— run a command in its network namespacedocker ps -a— containers and exit codesdocker logs <c>— container outputdocker inspect <c>— config, mounts, network, state
ReferenceWhat it is1 section · depth on demand
How it works
The kernel creates namespaces when the runtime calls clone() or unshare() with namespace flags. A process in a new PID namespace sees itself as PID 1, a new network namespace starts with only a loopback interface, and a mount namespace has its own mount table. The user namespace maps container UIDs to unprivileged host UIDs, which is what rootless containers rely on. Because every container still uses the host kernel, a kernel vulnerability or a privileged container can break out of this isolation.
ReferenceImportant terms & boundaries2 sections · depth on demand
Common mistakes
- Assuming namespaces alone give strong isolation.
In depth
A container is an ordinary process placed in its own set of namespaces. Each namespace type isolates one kind of resource:
| Namespace | Isolates | Seen inside the container |
|---|---|---|
| pid | Process IDs | Own PID 1; cannot see host processes |
| net | Interfaces, routes, iptables, sockets | Own eth0, own loopback |
| mnt | Mount table | Image root filesystem and volumes only |
| uts | Hostname, domain name | Container hostname |
| ipc | System V IPC, POSIX queues | Own shared memory |
| user | UID/GID mapping | Root in the container can map to an unprivileged host UID |
| cgroup | View of the cgroup tree | Own cgroup as root |
Worked check — prove which namespaces a container shares with the host
PID=$(docker inspect -f '{{.State.Pid}}' web)
ls -l /proc/$PID/ns/net /proc/1/ns/net
# net:[4026532281] vs net:[4026531840] → different inode = own network namespace
nsenter -t $PID -n ip -br addr # host's ip binary, container's network view
If both links show the same inode number, the container shares that namespace with the host (for example --network host).
Limits of the model
- All containers share one kernel. A kernel vulnerability or an exposed host device crosses every namespace boundary.
- Without a user namespace, UID 0 in the container is UID 0 on the host; capabilities and seccomp are then the main protection.
- Some kernel interfaces are not namespaced at all (for example most of
/sys, the kernel keyring and the system clock); runtimes mask or mount them read-only.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.