---
topic: tooling
author: Crashtech Editorial
published: Nov 13, 2026 · read: 3 min
---

What docker run Actually Does: Daemon, containerd, runc, Namespaces, cgroups

A container is a normal Linux process with isolation and limits. Follow one docker run from the CLI through dockerd and containerd to kernel namespaces.

– –

“Containers are lightweight VMs” is the most common wrong sentence in infrastructure. It is wrong in ways that matter: for performance, for security and for debugging. Walk one docker run through the machine and the correct picture appears.

The three Docker components

  • Client: the docker CLI. It does not run containers. It sends API requests.
  • Host (daemon): dockerd listens for API requests and manages images, containers, networks and volumes.
  • Registry: where images are stored. Docker Hub is the best known, and companies run private ones.

Follow one command

docker run -d --memory 256m -p 8080:80 nginx
  1. The CLI calls the daemon

    The client sends an API request over a Unix socket to dockerd. Nothing has started yet.

  2. The image is resolved and pulled

    If the nginx image is not local, the daemon pulls it from the registry. An image is a stack of read-only layers, each a filesystem diff, identified by content digests. Layers already on disk are reused, which is why a second pull is fast.

  3. The daemon delegates to containerd

    dockerd hands lifecycle work to containerd, a separate daemon that manages images and container processes. Behind it sits an OCI-compliant runtime, typically runc.

  4. runc asks the kernel for isolation

    runc creates the process with new namespaces and places it in a cgroup with your limits (--memory 256m). It sets up the root filesystem from the image layers plus a thin writable layer, then starts the container’s command.

  5. Networking and port mapping

    A virtual network interface is attached and port 8080 on the host is forwarded to port 80 in the container. The process is now running, and ps on the host will show it as an ordinary process.

The kernel does the real work

Namespaces: what it can see isolation
Separate views of process IDs, network interfaces, mounts, hostname, IPC and user IDs. Inside, the container’s main process is PID 1 and sees only its own filesystem and network.
cgroups: how much it can use limits
Caps and accounting for CPU, memory, I/O and process counts. Exceed the memory limit and the kernel kills the process (an OOM kill), which is the usual cause of mysteriously restarting containers.
Layered filesystem images
Read-only layers shared across images, with a copy-on-write layer on top. Writes land in the thin top layer and vanish with the container unless you use a volume.
OCI standards interoperability
Image and runtime formats are standardized, so images built with one tool run under other compliant runtimes.
Same kernel, different risk

Because containers share the host kernel, isolation is weaker than a VM’s. A kernel vulnerability or a misconfigured privileged container can expose the host. Run as non-root, drop capabilities, avoid privileged mode, and treat the Docker socket as root access.

Advertisement

Why this model changes how you debug

SymptomWhat it usually means
Container exits immediatelyThe main process ended or crashed, containers live as long as PID 1
Restarts with no errorOOM kill from a cgroup memory limit
Data gone after restartWrites went to the ephemeral layer, not a volume
Works locally, fails in CIDifferent base image layers, architecture or kernel features
Cannot reach the appPort not published, or listening on 127.0.0.1 inside the container

Do

Keep one main process per container, store state in volumes, set memory and CPU limits, and run as a non-root user.

Don't

Treat a container like a VM: SSH into it, install packages by hand, and rely on its writable layer. Rebuild the image instead.

Takeaway

Docker is an interface over Linux features. The CLI calls a daemon, the daemon pulls layers and delegates to containerd and runc, and the kernel isolates a plain process with namespaces and limits it with cgroups. Hold that model and containers stop being magic, and their failure modes become predictable.

Advertisement

Frequently asked questions

Is a container a lightweight virtual machine?

No. A virtual machine runs its own kernel on virtualized hardware. A container is an ordinary process on the host kernel, isolated using Linux namespaces and limited using cgroups. That is why containers start in milliseconds and share the host's kernel, which also means a kernel vulnerability affects all of them.

What do Linux namespaces do?

They give a process its own view of a system resource: process IDs, network interfaces, mount points, hostname, inter-process communication and user IDs. Inside its namespaces the container sees only its own processes and filesystem, even though they all run on the same kernel.

What do cgroups do?

Control groups limit and account for the resources a group of processes can use, such as CPU, memory and I/O. Namespaces decide what a container can see, cgroups decide how much it can use. Without cgroup limits, one container could consume all the host's memory.

Why is access to the Docker socket dangerous?

The Docker daemon usually runs as root, and its socket accepts commands to start containers. Anyone who can talk to it can launch a container that mounts the host filesystem, which is effectively root on the host. Never expose the socket to untrusted workloads.

Sources & further reading

/* Comments */