When we run docker run alpine sh , it feels like we just booted a tiny virtual machine. We get a new hostname, a new filesystem, our shell is PID 1, and the rest of the system seems to have disappeared.
But there's no virtual machine here. The shell is just a regular process on the host, started with a few Linux kernel features that limit what it can see and how much it can use. Docker, containerd, and runc are all tooling built around those features, and underneath it all, it's just a handful of system calls.
In this article, we will build our own container runtime using those system calls in about 250 lines of Go.…