Pcornel
Containers · Container Fundamentals

Linux Namespaces

Cheat sheet · https://pcornel.dk/topic.php?topic=6119

Back to the Topic

Answer

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.

Remember

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.

First checks

  • lsns -p <pid> — namespaces of a process
  • nsenter -t <pid> -n <cmd> — run a command in its network namespace
  • docker ps -a — containers and exit codes
  • docker logs <c> — container output
  • docker inspect <c> — config, mounts, network, state

Verify in this order

process → set of namespaces → isolated views

Where it usually breaks

Running with --network host, --pid host or --privileged removes isolation that users often assume is there.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=6119

Confirmation

Confirm action

Continue?