Session

Build Your Own Container Runtime in Go

We all run containers. Most of us couldn't build one. In this hands-on workshop I strip away the "magic" and we build a minimal container runtime from scratch — in Go, live — using nothing but the Linux kernel primitives that make isolation possible. No Docker, no runc.

We start from a single process and progressively wrap it in the four pillars of containerisation: namespaces (what a container can see), cgroups v2 (what a container can use), capabilities (what a container can do), and a pivoted root filesystem (where a container lives). By the end you'll have a working mycontainer run command that isolates PID, mount, UTS and network namespaces — and you'll understand exactly what docker run has been doing on your behalf all along.

What we build, step by step:

* Namespace isolation via syscall.SysProcAttr (CLONE_NEWPID, CLONE_NEWNS, CLONE_NEWUTS)
* Resource limits by writing to the cgroup v2 hierarchy (memory.max, cpu.max, pids.max)
* Root filesystem isolation with pivot_root and controlled mount propagation
* A correctly-reaped init process — because PID 1 has responsibilities most people forget

Takeaways:

* A mental model of a container as "a process wearing a costume", not a virtual machine
* The actual syscalls and /sys interactions behind every container you've ever run
* A complete, commented Go codebase to take home and extend

Prerequisites: a Linux machine or VM, Go 1.22+, and comfort at the command line. Intermediate Go assumed; no prior kernel experience required.

Ajitem Sahasrabuddhe

Staff DevOps Engineer, Automattic

Nagpur, India

Actions

Please note that Sessionize is not responsible for the accuracy or validity of the data provided by speakers. If you suspect this profile to be fake or spam, please let us know.

Jump to top