Series1 partВиталий Лещенко

Linux Containers by Hand

A Linux container is an ordinary process that the kernel presents with its own namespaces, filesystem root, and resource limits. In this series, we work from the top down, removing one layer of tooling at each step: we start with containerd and its clients, then launch a container with a single runc command, build one with shell commands, examine image layers, resources, networking, and security, and finish with a small C program that does it all itself.

Each part uses a clean virtual machine running Ubuntu Server 26.04, and all output was captured on that machine. The examples are available in the linux-containers-by-hand repository.

  1. Part 1

    Installing containerd without Docker or Kubernetes

    On Ubuntu 26.04, install containerd and runc from GitHub releases and start a container with ctr run. The host sees it as a process with its own namespaces. After runc exits, the shim remains the parent. The containerd client invokes the CNI plugins for networking, and nerdctl passes memory and CPU limits through the OCI spec to cgroup v2.

The series is not finished: the next parts are on their way.

  • Part 2: Building an OCI bundle and running it with runc
  • Part 3: Building a container with unshare and pivot_root
  • Part 4: Building a container root from image layers
  • Part 5: Limiting process resources with cgroup v2
  • Part 6: Connecting a container with veth, a bridge, and NAT
  • Part 7: Restricting root privileges in a container
  • Part 8: Writing a container runtime in C