Docker is weird
A developer's journey into creating their own container runtime unearths the 'weird' Linux underpinnings of Docker, revealing it's less a virtual machine and more a trench coat of kernel features. Hacker News dissects these technical revelations, with Docker's founder even joining the conversation to shed light on its historic design choices and enduring impact. The discussion celebrates Docker's user experience innovations while debating its technical quirks and alternatives.
The Lowdown
Embarking on a personal quest to build a container runtime from scratch, the author discovers that Docker, despite its ubiquitous presence, operates on several 'weird' and often misunderstood principles. This deep dive demystifies the magic, revealing the raw mechanics beneath the abstraction.
- Containers Aren't Virtual Machines: Unlike VMs, containers are merely isolated processes, leveraging existing kernel features rather than emulating hardware. They are visible as regular processes in
/proc. - The Linux Trench Coat: The concept of a 'container' doesn't exist as a single Linux feature; instead, it's a clever orchestration of several primitives: namespaces for isolation (process, network, mount, etc.), cgroups for resource limiting, and network trickery for connectivity.
- Images Are Just Folders: Docker images are essentially packaged directories. When run, Docker uses
chrootorpivot_rootto make this directory the container's new root filesystem. - Go's Conundrums for Runtimes: The article posits that Go, the language powering Docker's
runc, has design choices (like a natively multi-threaded runtime and lack of truefork) that complicate its use for container orchestration, necessitating custom C modules and workarounds. - Root Privileges (Historically): Many Linux kernel APIs crucial for container runtimes traditionally required root access, explaining why the Docker daemon typically runs as root. While rootless options now exist, they often involve reimplementing networking in userspace.
Ultimately, the author concludes that tackling the challenge of reimplementing a widely used tool is an incredibly effective way to deepen one's understanding of its underlying mechanisms and design trade-offs.
The Gossip
The Founder's Fortuity
Solomon Hykes, Docker's original creator, serendipitously appeared in the comments, sparking a lively Q&A. Users expressed deep gratitude for Docker's impact, asking about its genesis, evolution, current projects (Dagger), and personal motivations. Hykes acknowledged the challenges, the context of Go's selection, and his continued use and evolution of container concepts.
Daemon Debates & Rootless Ruminations
The article's critique of Docker requiring root spurred debate about its client/server daemon architecture. Commenters discussed its historical necessity for privilege escalation, compared it to daemonless alternatives like Podman, and acknowledged how user namespaces later enabled rootless containers, changing the landscape.
Go's Gaffes in Container Crafting
The author's assertion that Go is a "terrible language" for container runtimes resonated with some, who elaborated on its multi-threading and `fork` limitations requiring C-modules. Others defended the historical choice, noting Go's maturity at the time and the undeniable success of Go-based runtimes, while conceding Rust might be a better modern choice.
The 'Magic' of Docker's Marketing & UX
While the article focused on technical internals, many comments highlighted Docker's innovative user experience—the Dockerfile concept, layered images, and a central registry—as the true game-changers, simplifying complex isolation and deployment for the masses, which was its "selling point." Some also noted how containers, when properly understood, provide an 'idempotent language for OS-level dependencies'.
Demystifying Container Internals
The core premise of the article—that "containers aren't real" but rather a sophisticated orchestration of Linux primitives—was widely affirmed. Commenters expanded on the role of namespaces, cgroups, and `chroot`, often recommending further resources or reflecting on the evolution of these concepts, with some finding the author's 'weird' label surprising given the natural evolution of these technologies.