Container khác gì so với VM? Cách container hoạt động ở cấp OS?

VM (Virtual Machine) dùng hypervisor (VMware, KVM, VirtualBox) virtualize toàn bộ hardware, mỗi VM có OS kernel riêng — strong isolation, có thể chạy Windows trên Linux host; overhead: mỗi VM tốn hàng GB RAM cho OS, boot time hàng phút. Container share kernel của host OS, chỉ isolate userspace — nhỏ hơn (MB thay vì GB), start trong milliseconds, dense packing (hàng trăm containers/host).

Container không phải magic: đó chỉ là Linux process với namespace isolation và cgroup resource limits. Docker thực ra tạo:

  1. Namespaces: PID namespace (container có PID 1 riêng), Network namespace (interface riêng), Mount namespace (filesystem riêng), UTS (hostname riêng), IPC, User namespace
  2. cgroups giới hạn CPU/memory/disk I/O/network
  3. Union filesystem (overlay2) cho image layers. docker run thực sự gọi clone(CLONE_NEWPID | CLONE_NEWNET | ...)

Bảo mật: container escape là lỗ hổng khai thác syscall để thoát namespace; privileged container nguy hiểm vì bỏ qua nhiều restriction.

Xem toàn bộ Operating System cùng filter theo level & chủ đề con.

Mở danh sách Operating System