Deep Dive into Docker and Kubernetes Resource Management Using Linux Namespaces and Cgroups
The article explains how Docker and Kubernetes use Linux namespaces to isolate processes, network, IPC, mounts, UTS and users, and employ cgroups to enforce CPU, memory and I/O limits, detailing Docker’s architecture, Kubernetes’s millicore‑based resource model, QoS classes, and the hierarchical pod‑level cgroup structure.
This article provides a comprehensive explanation of how Docker and Kubernetes leverage Linux namespaces and control groups (cgroups) to isolate and manage container resources.
It begins with an overview of virtualization technology, defining it as the abstraction of hardware resources to enable multiple systems to run on a single host, improving utilization and reducing costs.
The discussion then moves to Docker, describing its client/server architecture, the Docker daemon (dockerd), containerd, runc, and the roles of images, containers, registries, and the default bridge network docker0.
Docker’s use of Linux namespaces—including PID, network, IPC, mount, UTS, and user namespaces—is detailed, showing how each namespace isolates specific system resources such as process IDs, network interfaces, inter‑process communication, filesystems, hostnames, and user IDs.
Control groups are introduced as the mechanism for limiting, accounting, and isolating resource usage (CPU, memory, I/O) of groups of processes, with examples of how Docker translates run options like --cpus, --memory, and --device‑read‑bps into cgroup settings.
The article further explains Kubernetes’ resource model, where CPU is measured in millicores and memory in bytes, and how requests and limits define three QoS classes: Guaranteed, Burstable, and BestEffort.
Finally, it walks through the hierarchical cgroup layout that Kubernetes creates for pods, mapping pod‑level and container‑level cgroups under kubepods.slice, QoS slices, and the docker‑*.scope directories, illustrating how resource enforcement is applied in practice.
NetEase Media Technology Team
NetEase Media Technology Team
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.