CSE Roadmap

Common tier · about 2 hours · 6 parts

Part 3 of 6 · 2 min read

Containers

A private process space that shares the host's kernel.

BM describes Linux containers as an alternative to virtualisation. Instead of a hypervisor, a container creates a separate process space. The Linux kernel already keeps a tree of processes. Each container is effectively a subtree of it, and the kernel can assign physical resources, such as memory and CPU, to each one. BM names LXC as the popular form, built into modern Linux kernels.

Differences from VMs, per BM: - No hypervisor is needed. - Each container may have its own operating system distribution, but all share the same kernel. A host on Ubuntu can run containers based on CentOS. - Containers start in seconds, where a VM can need many minutes, so feedback is faster. - Resources can be assigned in finer pieces. - Many more fit on the same hardware, so one service per container costs far less than one service per VM. A made-up illustration: a host that can hold 8 VMs might hold 80 containers of the same size.

BM adds cautions: - The outside world must be routed to the containers, and BM saw people lose much time configuring port forwarding by hand. - Containers are not completely sealed from each other. Known ways exist for a process to break out and affect other containers or the host. BM's advice: if you do not trust the code, do not expect a container to make it safe. Use virtual machines for that level of isolation.

BM also says containers and VMs can be combined: run containers on a large cloud VM, getting on-demand machines plus quick containers.

Container

A container is an isolated group of processes with its own file system view and resource limits, sharing the host's kernel.

Example: the checkout service and its libraries run in one container. A second container on the same host runs the search service with different library versions, and neither sees the other's files.

Check yourself: 1. What do all containers on a host share? 2. Why do containers start faster than VMs? 3. When does BM advise a VM instead of a container?