Skip to main content
InterviewHubPRO
Section Overview
Q2

Question 2 of 50

Part 1: Basic & Foundational Concepts (Junior / Entry-Level)

4%
Docker & Containers (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)

Containers vs. Virtual Machines (VMs): How do Linux Namespaces and Control Groups (cgroups) isolate processes?

junior LevelDocker & Containers

In Simple Words:

  • Virtual Machines: Virtualize physical hardware via a Hypervisor (Type 1 like ESXi or Type 2 like VirtualBox). Each VM boots a full guest OS kernel, consuming gigabytes of RAM and taking minutes to start.
  • Containers: Virtualize at the operating system level. All containers share the single host Linux kernel. They run as standard Linux processes isolated by two native kernel primitives:
    1. Namespaces (Isolation): Restricts what a process can see. Gives each container its own process table (PID), network interfaces (NET), filesystem mounts (MNT), and user IDs (USER).
    2. Control Groups / cgroups (Resource Metering): Restricts how much a process can use. Enforces hard limits and quotas on CPU, RAM, disk I/O, and pids.
FeatureVirtual Machines (VMs)Docker Containers
KernelSeparate guest kernel per VMShared host OS kernel
Startup TimeMinutes (boots full OS)Milliseconds to seconds (starts process)
Resource OverheadHigh (GBs of RAM reserved)Minimal (MBs of RAM per container)
IsolationHardware-level (Hypervisor boundary)Kernel-level (Namespaces & cgroups)