Docker & Containers (50 Qs)•Part 3: Advanced Internals, Scale & Production Security (Senior / Lead)
Deep Dive into the 7 Linux Namespaces: How the Kernel Implements Container Isolation.
senior LevelCode ExampleSecurity & AuthDocker & Containers
In Simple Words: Namespaces wrap global system resources in an abstraction such that processes within the namespace believe they have their own isolated instance of that resource.
- PID (Process IDs): Isolates process IDs. The container entrypoint becomes PID 1 inside the container, while retaining its true host PID (e.g., 4289) on the host.
- NET (Networking): Isolates network devices, IP routing tables, port bindings, and firewall iptables.
- MNT (Mount Points): Isolates filesystem mount points. The container sees only its
pivot_rootmount point. - IPC (Inter-Process Communication): Isolates System V IPC and POSIX message queues and shared memory segments (
shm). - UTS (Hostnames): Isolates nodename and domainname (
hostnamecan be set uniquely per container). - USER (User & Group IDs): Maps container UID 0 (root) to an unprivileged host UID (e.g., UID 100000).
- CGROUP (Control Group): Isolates the view of cgroup hierarchies within
/proc/self/cgroup.
objectivec
Linux Kernel Syscall: clone(flags = CLONE_NEWPID | CLONE_NEWNET | CLONE_NEWNS | CLONE_NEWIPC | CLONE_NEWUTS)