Container Internals

Concept

A container is not a lightweight VM.
It is a regular Linux process (or group of processes) isolated using kernel features:

  • Namespaces – isolate what the process can see (PID, network, mount, UTS, IPC, user…)
  • cgroups – limit and account for resources (CPU, memory, I/O…)
  • Union / overlay filesystems – give the appearance of a private root filesystem

Why it matters

Understanding the underlying mechanisms helps when:

  • Debugging “why can this container see X?”
  • Investigating resource limits and OOM kills
  • Working with network or storage problems inside containers
  • Moving between Docker, containerd, Podman, and Kubernetes

Mental Model

Host Kernel
├── Namespaces (isolation of view)
├── cgroups (resource limits)
└── Process(es) with a private rootfs (overlay)

From the inside, a container looks like its own small system.
From the host, it is just processes with special settings.

Key Concepts

FeaturePurpose
PID namespaceIsolated process tree
Network namespaceIsolated network stack (interfaces, routes)
Mount namespacePrivate filesystem mount table
User namespaceMap container UIDs to different host UIDs
cgroupsCPU / memory / I/O limits and accounting
OverlayFSLayered filesystem for images

Useful Host Commands

# See namespaces of a process
lsns
ls -l /proc/<PID>/ns
 
# cgroup information
cat /proc/<PID>/cgroup
 
# What the container’s root looks like on the host (Docker example)
docker inspect <container> | grep -i upperdir
 
# Processes inside a container from the host
docker top <container>
# or
ps aux | grep <container-process>

Common Failure Modes & Symptoms

SymptomRelated internal concept
Process sees wrong networkNetwork namespace
Cannot write to expected pathsMount namespace / volumes / permissions
OOMKilledcgroup memory limit
Permission denied on filesUser namespace + file ownership
“No space left” inside containerOverlay / writable layer full

Investigation Tips

  • When a container has network problems, check whether it is using the host network or its own network namespace.
  • Resource limits defined in Kubernetes or Docker end up as cgroup settings on the host.
  • Overlay filesystem issues can look like normal disk-full problems but are limited to the container’s writable layer.

Personal Lessons Learned