runc

On this page 7

runc is a low-level container runtime: a small command-line program that creates and starts Linux containers from an OCI bundle, exactly as defined by the Open Container Initiative runtime specification. In cloud infrastructure and the wider field of Containers, it is the component that finally asks the Linux kernel to build the isolated process that everyone calls a container.

Most engineers never invoke runc directly. Higher-level tools such as containerd, Docker, Podman and Kubernetes pull images, manage networks and handle lifecycles, then delegate the actual process creation to runc. Because it sits at this boundary, runc is both the reference implementation of the OCI runtime standard and a security-critical piece of nearly every container platform.

How runc creates a container

runc creates a container by reading a bundle directory and translating its configuration into Linux kernel primitives. A bundle contains a config.json file and a root filesystem (usually called rootfs), which the caller has already unpacked from a container image. runc itself never downloads images and never manages layers.

The creation sequence follows a fixed pattern. runc parses the configuration, clones a new process into the requested namespaces, applies cgroup limits, mounts the filesystem tree, switches the root with pivot_root, drops capabilities, loads seccomp filters and finally executes the user’s entry process. Part of this work happens in a small helper stage called runc init, which runs inside the new namespaces before the real program replaces it.

The table below lists the main kernel features that runc configures and what each one contributes to isolation.

Kernel featureWhat runc sets upEffect on the container
NamespacesPID, mount, network, UTS, IPC, user, cgroupSeparate view of processes, files and hostnames
Control groupsCPU, memory, PIDs and I/O limitsBounded resource consumption
CapabilitiesReduced set of root privilegesSmaller attack surface for root inside
SeccompSystem call allow or deny listBlocks dangerous kernel interfaces
LSM profilesAppArmor or SELinux labelsMandatory access control on files and sockets
MountsRoot filesystem, /proc, /dev, volumesPrivate filesystem view
Kernel features configured by runc

The runc lifecycle and commands

runc exposes the OCI lifecycle operations as subcommands, so a caller can control each state transition separately. The split between create and start matters: a container can be fully prepared, inspected and connected to a network before its workload begins to run.

The following table summarizes the commands that orchestrating software uses most often and the state each one produces.

CommandPurposeResulting state
runc createBuilds namespaces and cgroups, waitsCreated
runc startExecutes the configured user processRunning
runc runCombines create and start in one stepRunning
runc execStarts an extra process inside the containerRunning (unchanged)
runc pauseFreezes all processes through the cgroup freezerPaused
runc killSends a signal to the init processStopped after exit
runc deleteRemoves runtime state and cgroupsDeleted
Core runc commands and resulting states

runc stores its runtime state in a directory such as /run/runc, keyed by container ID. It is not a daemon: each command starts, performs one operation and exits. Long-lived supervision is the job of a shim process such as containerd-shim-runc-v2, which keeps standard input and output open, collects the exit code and lets containerd restart without killing running containers.

Where runc sits in the container stack

runc occupies the lowest layer of the runtime stack, directly above the kernel. Higher layers handle images, storage, networking and APIs, and they call runc only when a process must be created or controlled. This layering explains why the same runc binary serves very different products.

The table compares runc with neighboring components that are often confused with it.

ComponentLayerMain responsibility
runcLow-level OCI runtimeCreate and control one container process tree
containerdHigh-level runtimeImage pull, snapshots, lifecycle via shims
CRI-OKubernetes runtimeImplements the Kubernetes CRI using OCI runtimes
Docker EngineDeveloper platformAPI, builds, networking, calls containerd
crunAlternative OCI runtimeSame role as runc, written in C
Kata ContainersSandboxed OCI runtimeRuns each pod inside a lightweight virtual machine
gVisor (runsc)Sandboxed OCI runtimeIntercepts system calls in a user-space kernel
runc compared with related container components

Because all of these runtimes accept the same OCI bundle format, an operator can swap runc for crun, Kata Containers or gVisor through a runtime class in Kubernetes without changing images. runc remains the default choice in Docker, containerd and most managed Kubernetes services.

Origins and relationship to the OCI

runc began as libcontainer, the execution library that Docker wrote to replace its dependency on LXC. In 2015 Docker donated the code to the newly formed Open Container Initiative, where it became the reference implementation of the OCI runtime specification. The project is written in Go, with a small C component for the early namespace setup that Go cannot perform safely in a multithreaded process.

Its status as a reference implementation has practical consequences. New specification features usually appear in runc first, and conformance with runc behavior is the informal test that other runtimes aim to pass. The project also supports rootless containers, in which an unprivileged user creates containers through user namespaces without root on the host.

Security considerations and failure modes

runc shares the host kernel with every container it creates, so its isolation is only as strong as the kernel features it configures. A flaw in runc or in the kernel can turn into a container escape. The well-known CVE-2019-5736 allowed a malicious container to overwrite the host runc binary, and CVE-2024-21626 exploited a leaked file descriptor to reach the host filesystem. Both were fixed quickly, but they show why prompt runc patching is a baseline control.

The table lists frequent operational problems, their typical causes and the usual remedies.

SymptomLikely causeRecommended fix
Container escape advisoryOutdated runc versionUpgrade runc and restart affected nodes
Permission denied at startSeccomp or LSM profile too strictAdjust the profile, never disable it globally
cgroup errors on new hostscgroup v1 and v2 mismatchAlign the cgroup driver with the host
Orphaned containersShim crashed or state directory lostClean up with runc delete and restart the shim
Rootless start failsMissing subordinate UID or GID rangesConfigure /etc/subuid and /etc/subgid
Common runc problems and fixes
  • Avoid privileged mode unless a workload truly needs direct device access.
  • Keep default seccomp and capability settings as the starting point for hardening.
  • Use a sandboxed runtime for untrusted multi-tenant code, where shared-kernel isolation is insufficient.

A plain-language summary

runc is the small worker that actually starts a container. Other tools prepare everything: they download the image, unpack the files and decide the settings. Then they hand the job to runc, which asks the operating system to build a walled-off space and launch the program inside it.

A useful comparison is a stage crew. Docker or Kubernetes plans the show, while runc raises the walls, sets the lights and opens the curtain. It does one job, quickly and by a shared standard, which is why so many platforms rely on it.

An example from practice

A platform team runs a Kubernetes cluster of 40 worker nodes that host internal web services. Each node uses containerd, and containerd starts every pod container through runc. When a security advisory for a runc container escape is published, the team checks the installed version on each node and finds that all nodes run a vulnerable release.

The engineers drain the nodes in batches of five, upgrade the containerd package that bundles the patched runc binary and return each batch to service. The whole rollout takes about two hours with no application downtime, because Kubernetes reschedules pods to patched nodes.

For a separate cluster that runs customer-supplied code, the team also defines a runtime class that uses a sandboxed OCI runtime instead of runc. The outcome is a patched default runtime for trusted workloads and stronger isolation for untrusted ones, without any change to the container images.