Build a minimal container in Go to understand what Docker does.
A Linux process with three things:
- Namespaces - Isolate what it sees (PIDs, network, filesystem, hostname)
- Cgroups - Limit resources (CPU, memory, I/O)
- Root filesystem - Its own files and libraries
Linux:
sudo go run main.go run /bin/shmacOS/Windows:
docker run -it --privileged golang:latest bash
# Then run the code insideWhy? Containers need Linux kernel features that macOS/Windows don't have.
- Parent creates new namespaces
- Child runs inside isolation as PID 1
- Process can't see host processes or share hostname
Real containers also have: image layers, networking, security policies, resource limits, OCI compliance.