Docker is weird
- The author started building a toy container runtime and highlighted several counterintuitive details about how Docker works under the hood.
- Containers are not virtual machines; they are standard host processes constrained by kernel mechanisms and remain directly inspectable in
/proc. - Linux lacks a single native "container" feature, relying instead on combined kernel primitives:
- Namespaces to isolate visibility (process trees, mounts, networks).
- Control groups (cgroups) to enforce resource boundaries like CPU and memory limits.
- Routing and virtual networking interfaces to isolate network traffic.
- Container images are fundamentally directory trees unpacked on the host; Docker isolates them by invoking
pivot_rootorchrooton the unpacked filesystem. - Go introduces notable friction when implementing container runtimes like
runc:- Go's multi-threaded runtime conflicts with Linux syscalls that require single-threaded execution, necessitating a C bootstrap module (
cgo) that executes before the Go runtime initializes. - Go does not provide a standard
fork(), forcingruncto re-execute/proc/self/exewith internal flags to simulate process cloning before callingexec.
- Go's multi-threaded runtime conflicts with Linux syscalls that require single-threaded execution, necessitating a C bootstrap module (
- Docker traditionally requires root privileges to configure kernel namespaces and networking, whereas rootless container runtimes must manage complex network virtualization in userspace.
Hacker News Discussion
- Docker creator Solomon Hykes (
shykes) joined the thread, discussing the early days of Docker, the transition to his current project (Dagger), and the design tradeoffs made during Docker's inception. - Hykes recounted Docker's 2013 debut—an impromptu 5-minute lightning talk on the main stage at PyCon US after riding there on a motorcycle—which immediately caused an unexpected rush of interest at the dotCloud sponsor booth.
- Commenters discussed Docker's underlying lineage, with Hykes clarifying that early versions derived from OpenVZ before moving to LXC, and eventually replacing LXC with their own pure Go implementation (
libcontainer) due to instability. - Discussion addressed Docker's historical commercialization hurdles, which Hykes attributed to cultural silos between open-source and enterprise teams and an unfocused product roadmap rather than developer-facing feature gaps.
- Developers shared nostalgia regarding how Docker solved the ubiquitous "works on my machine" problem, while comparing modern container-based local development environments against earlier tools like Vagrant and LXC.