AWS Builder Center
Containers Don’t Run in Docker. They Run in the Linux Kernel.

Containers Don’t Run in Docker. They Run in the Linux Kernel.

The Foundation (Namespaces, Cgroups, and Why Docker Doesn’t Matter)

Most engineers think Docker runs containers. It doesn’t. The Linux kernel does.
Docker, containerd, runc, CRI they’re just layers on top of that fact.
When you type  docker run , you’re not “running Docker.” You’re asking the Linux kernel to create isolated namespaces, enforce resource limits through cgroups, and mount a layered filesystem. Docker is the friendly interface that makes these syscalls for you.
This matters more than you think.
Because when you move to Kubernetes and hear “Docker is deprecated,” you panic. When you see containerd, CRI-O, and runc in architecture diagrams, you’re confused. When something breaks, you don’t know which layer failed.
Here’s the stack you’re actually using:
┌─────────────────────┐
│ Kubernetes │ Orchestration
└─────────────────────┘
↓
┌─────────────────────┐
│ containerd │ Lifecycle manager
└─────────────────────┘
↓
┌─────────────────────┐
│ runc │ Kernel interface
└─────────────────────┘
↓
┌─────────────────────┐
│ Linux kernel │ WHERE CONTAINERS ACTUALLY EXIST
└─────────────────────┘
This article unpacks each of these layers, starting from the bottom.
Part 1 (this article) covers the kernel foundation: namespaces, cgroups, and overlay filesystems. The primitives that make containers possible.
Part 2 (coming next) explains OCI standards, runc, and containerd—the layers that manage those primitives.
Part 3 (final) shows how Kubernetes plugs into this stack via CRI, why dockershim was removed, and what happens when you deploy a pod.
By the end, you’ll understand exactly which layer does what and where to look when things break.
Let’s start where containers actually become real: the Linux kernel.



Containers Are Not Virtual Machines (Stop Thinking They Are)

The biggest misconception in containerization: treating containers as “lightweight VMs.”
This mental model breaks as soon as you go deeper.
Virtual machines run a complete operating system with its own kernel. Containers share the host kernel. That’s not a detail it’s fundamental to everything that follows.
What a VM gives you:
  • Hardware virtualization via hypervisor
  • Complete OS isolation (different kernels can run side by side)
  • Boot time measured in seconds or minutes
  • Strong security boundaries at the hardware level
What a container gives you:
  • Process-level isolation using kernel features
  • Same kernel, different views
  • Start time measured in milliseconds
  • Lighter security boundaries (same kernel attack surface)
Here’s the critical insight:
A container is just a Linux process with restrictions applied by the kernel.
When you start a container, you’re not booting an OS. You’re forking a process and telling the Linux kernel:
  1. Isolate what this process can see (namespaces)
  1. Limit what resources it can use (cgroups)
  1. Give it a different filesystem view (mount namespace + overlay storage)
That’s it. No virtual hardware. No guest kernel. No hypervisor.
Everything in the container ecosystem Docker, containerd, runc, Kubernetes—exists to orchestrate these three kernel features in useful ways.
Let’s examine each one.



Where Containers Actually Become Real

Forget Docker for a moment. Forget containers as a concept. Let’s talk about what your Linux kernel can do.
The Linux kernel has three features that, when combined, create what we call “containers”:
1. Namespaces - Isolation of what a process can see 2. Cgroups - Limits on what a process can use 3. Overlay Filesystems - Efficient layered storage
These aren’t “container features.” They’re general-purpose kernel capabilities that existed before Docker. Docker (and everything else) just orchestrates them.
Let’s break down each one.



Namespaces: Creating Separate Realities

Namespaces control what a process can see. They let multiple processes exist on the same machine but see different versions of reality.
Think about running two web servers that both want to bind to port 80. Normally, they’d conflict. But put them in separate network namespaces, and each sees its own network stack. No conflict. Each server thinks it owns port 80.
This is the core of container isolation.
Linux provides seven types of namespaces:
PID Namespace - Process isolation Your containerized app sees itself as PID 1. It can’t see processes outside its namespace. As far as it knows, it’s the only thing running on the system.
Network Namespace - Network isolation Separate network interfaces, IP addresses, routing tables. That’s how containers each get their own IP address and can all bind to the same port numbers.
Mount Namespace - Filesystem isolation Different view of mounted filesystems. Your container sees  /  as its root, while the host sees something completely different at that path.
UTS Namespace - Hostname isolation Each container gets its own hostname. Simple, but necessary.
IPC Namespace - Inter-Process Communication isolation Separate message queues, semaphores, shared memory segments. Prevents containers from communicating via shared memory.
User Namespace - User ID isolation Maps user IDs inside the container to different IDs outside. This lets you run as root inside a container while being an unprivileged user on the host.
Cgroup Namespace - Control group isolation Hides the host’s cgroup hierarchy from the container.
See it in action:
# Create a new PID namespace
unshare --fork --pid --mount-proc bash

# You're now in a new namespace
ps aux # Shows only processes in this namespace
From inside that bash shell, you can’t see processes from the host. You’ve created an isolated process tree.
Namespaces answer one question: “What can this process see?”
They don’t limit resource usage. That’s where cgroups come in.

Cgroups: The Resource Police

Namespaces let you isolate what a process sees. But what stops a container from using all your CPU? Or eating all your memory?
Cgroups (control groups).
Cgroups limit how much of each resource a process can consume. They’re the kernel’s built-in resource accounting and limiting system.
What cgroups control:
CPU - Limit processor time You can give a container 50% of one core, or 2 full cores, or burst access with throttling. The kernel enforces it.
Memory - Hard limits on RAM Set a 512MB limit. If the container tries to allocate more, the kernel’s OOM (Out of Memory) killer terminates it.
Block I/O - Disk read/write rates Throttle a container to 1MB/s reads. Prevents one container from starving others of disk bandwidth.
Network - Bandwidth control When integrated with traffic control ( tc ), limits network throughput.
Device Access - Which devices can be used Whitelist access to specific devices like  /dev/null  while denying everything else.
How it works:
The kernel maintains a cgroup hierarchy at  /sys/fs/cgroup/ . You configure limits by writing to files in that hierarchy.
# Create a memory-limited cgroup
mkdir /sys/fs/cgroup/memory/mycontainer

# Set 512MB limit
echo 536870912 > /sys/fs/cgroup/memory/mycontainer/memory.limit_in_bytes

# Put process 1234 into this cgroup
echo 1234 > /sys/fs/cgroup/memory/mycontainer/cgroup.procs
Now process 1234 can’t use more than 512MB. If it tries, the kernel kills it. No exceptions.
Cgroups answer one question: “How much can this process use?”
Combine namespaces (isolation) with cgroups (limits) and you get the foundation of containers.

Put Them Together: This Is a Container

Namespaces + cgroups = container isolation.
  • Namespaces isolate what processes see
  • Cgroups limit what processes can use
A “container” is really just:
Process + Namespaces + Cgroups + Root Filesystem
That’s it. No virtualization. No magic. Just kernel features applied to a regular process.
But there’s one more piece: the filesystem.



Layered Filesystems: Why Containers Start Instantly

Containers need their own filesystem. But copying entire operating systems for every container would be absurdly wasteful.
You’d need gigabytes per container. Startup time would be measured in seconds. Disk space would vanish.
Union filesystems solve this.

The Layered Model

Container images are built in layers. Each layer represents a change to the filesystem. Layers stack on top of each other.
Example Dockerfile:
FROM ubuntu:20.04 # Layer 0: Ubuntu base (80MB)
RUN apt-get update # Layer 1: Package index (30MB)
RUN apt-get install nginx # Layer 2: Nginx binaries (50MB)
COPY index.html /var/www # Layer 3: Your file (4KB)
Total: 160MB stored on disk.
But here’s the trick: those layers are shared across all containers using that image.
Run 10 nginx containers, and they all use the same base layers. Only the top writable layer is unique per container.

Overlay2: The Modern Implementation

Docker uses overlay2 to implement layered filesystems. It works in three parts:
1. Lower layers (read-only) These are your image layers. Shared across containers. Never modified.
2. Upper layer (read-write) Created when the container starts. Stores all changes made by the running container.
3. Merged layer The union of all layers. This is what the container actually sees as its root filesystem.
Visual representation:
Container sees: /
↓
[Merged View]
↓
Overlay2 Mount
↓
┌──────────────────────┐
│ Upper Layer (R/W) │ ← Container writes here
├──────────────────────┤
│ Image Layer 3 (R/O) │ ← Your app files
├──────────────────────┤
│ Image Layer 2 (R/O) │ ← Nginx
├──────────────────────┤
│ Image Layer 1 (R/O) │ ← Updated packages
├──────────────────────┤
│ Image Layer 0 (R/O) │ ← Ubuntu base
└──────────────────────┘

Copy-on-Write in Action

When a container modifies a file that exists in a lower layer:
  1. Container tries to write to  /etc/nginx/nginx.conf 
  1. File exists in image layer (read-only)
  1. Overlay2 copies the entire file to the upper layer
  1. Container writes to the copy
  1. Original stays untouched in lower layer
This is copy-on-write (CoW). You only copy what you modify.
Why this matters:
  • Fast startup - No filesystem copy needed. Mount the layers and go.
  • Efficient storage - 100 containers might share the same 160MB base image.
  • Isolated changes - Each container’s modifications stay in its own upper layer.
  • Easy distribution - Push and pull individual layers, not entire filesystems.
Container images are distributed as layers. When you  docker pull nginx , you’re downloading compressed tar archives of each layer. The runtime extracts them and stacks them using overlay2.
Storage location on disk:
/var/lib/docker/overlay2/
├── abc123/ # Image layer
│ └── diff/ # Layer contents
├── def456/ # Image layer
│ └── diff/
└── xyz789/ # Container layer
├── diff/ # Read-write layer
├── merged/ # What container sees
└── work/ # Overlay2 internal
When the container stops, the upper layer can be committed as a new image layer or discarded.



The Mental Model: Containers Are Kernel Features

Let’s consolidate what you now understand.
Containers aren’t a thing. They’re three kernel features working together:
┌──────────────────────────────────────┐
│ Your Application │
│ (nginx, node, python...) │
└──────────────────────────────────────┘
↓
┌──────────────────────────────────────┐
│ Namespaces │
│ What can this process see? │
│ (PID, Network, Mount, IPC...) │
└──────────────────────────────────────┘
↓
┌──────────────────────────────────────┐
│ Cgroups │
│ How much can this process use? │
│ (CPU, Memory, I/O limits) │
└──────────────────────────────────────┘
↓
┌──────────────────────────────────────┐
│ Overlay Filesystem │
│ What files does this process see? │
│ (Layered, copy-on-write storage) │
└──────────────────────────────────────┘
↓
┌──────────────────────────────────────┐
│ Linux Kernel │
│ WHERE CONTAINERS ACTUALLY EXIST │
└──────────────────────────────────────┘
When you run a container, this happens:
  1. Kernel creates namespaces (PID, network, mount, etc.)
  1. Kernel enforces cgroups (memory limit, CPU quota)
  1. Kernel mounts overlay filesystem (base image + writable layer)
  1. Kernel executes your process inside this environment
That’s the entire foundation.
Everything else is tooling built on top of this foundation.
Docker doesn’t create containers. Neither does containerd. Neither does Kubernetes.
The Linux kernel creates containers.
Docker, containerd, runc—they’re layers of abstraction that make syscalls to the kernel on your behalf. They make these operations convenient, repeatable, and manageable at scale.
But the actual isolation, limiting, and filesystem mounting? That’s pure kernel.



Reality Check: Where Your Container Actually Lives

Right now, if you have a container running, here’s where it exists:
Not in Docker. Docker is a daemon that manages container lifecycle.
Not in containerd. containerd orchestrates image storage and calls lower-level runtimes.
Not in runc. runc executed the syscalls but doesn’t stick around.
In the kernel.
Your container is:
  • A process tree visible in  /proc 
  • Namespace entries in  /proc/<pid>/ns/ 
  • Cgroup controllers in  /sys/fs/cgroup/ 
  • Mounted overlay filesystem
  • Just another process
You can see this:
# Find a running container's main process
docker inspect <container-id> | grep Pid

# Look at its namespaces
ls -l /proc/<pid>/ns/

# Check its cgroup membership
cat /proc/<pid>/cgroup
There’s no virtualization layer. No container hypervisor. Just kernel features applied to a process.



What Comes Next: The Tooling Layers

Now that you understand where containers exist (the kernel), you’re ready to understand how we manage them.
The next layer up is the runtime tooling:
  • OCI standards - Why image formats and runtime specs matter
  • runc - The tool that makes those syscalls to the kernel
  • containerd - The daemon that manages container lifecycle
  • Docker - The platform that wraps everything in a friendly interface
Part 2 will unpack that entire chain: from OCI specifications through runc and containerd, ending with Docker’s role in the stack.
Part 3 will show how Kubernetes plugs into this via CRI, why dockershim was removed, and what happens when you deploy a pod.



Key Takeaways

Before you go:
1. Containers are kernel features, not virtual machines. Stop thinking of containers as “lightweight VMs.” They’re isolated processes.
2. Three kernel primitives create containers: Namespaces (isolation) + cgroups (limits) + overlay filesystems (storage).
3. The kernel is where containers actually exist. Everything else is management tooling on top.
4. Docker isn’t magic. It’s a friendly interface to kernel features. That’s why Kubernetes doesn’t need it.
5. When something breaks, know which layer to check:
  • Process won’t start? Check namespaces and cgroups.
  • Filesystem issues? Check overlay mounts.
  • Network problems? Check network namespace setup.
  • Resource limits hit? Check cgroup configuration.
You now understand the foundation. Next, we’ll build the tooling stack on top of it.



Further Reading for Part 1

Linux Kernel Documentation:
Hands-On Practice:
  • Use  unshare  to create isolated namespaces manually
  • Explore  /sys/fs/cgroup/  to see cgroup hierarchies
  • Use  nsenter  to enter a container’s namespaces
  • Run  lsns  to list all namespaces on your system
  • Trace syscalls with  strace  on a running container
Experiments to Try:
# See your container's network namespace
docker run -d nginx
docker inspect <container-id> | grep SandboxKey

# Enter that namespace
sudo nsenter --net=/var/run/docker/netns/<namespace> bash
ip addr # You're now inside the container's network view

# Check overlay mounts
mount | grep overlay

# See cgroup limits
cat /sys/fs/cgroup/memory/docker/<container-id>/memory.limit_in_bytes
Questions? Corrections? Understanding these fundamentals is critical for everything that follows. If something isn’t clear, that’s on me let me know.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article