Container isolation and its limits

Advanced · 13 min

What Docker actually puts around a container by default, why one shared kernel is the real boundary, and when you need gVisor or a microVM instead.

Before thisContainers vs virtual machinesThe Docker architecture: client, daemon and runtimes

Cloud Codes · 13 min

Container isolation and its limits

The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.

Taught by Cloud CodesReport a problem with this video
Not started
Set this lesson's status

What you'll learn

  • A default container gets its own mount, PID, network, IPC and UTS namespaces, plus a cgroup namespace on cgroup v2 and, since Engine 29.5, a time namespace. It does not get a user namespace.
  • On top of namespaces Docker drops to 14 capabilities, applies a seccomp filter, masks and makes read-only parts of /proc, and adds AppArmor or SELinux confinement where the host has it.
  • Every container still makes system calls to the one host kernel. A kernel bug reachable through an allowed system call can become a container escape.
  • Runtime bugs matter too. runc has had several container breakouts, including CVE-2024-21626 (Leaky Vessels) and three in November 2025.
  • Moby's threat model says the shared-kernel model itself is out of scope, and that stronger isolation needs a VM-based runtime.
  • Flags such as --privileged, --pid=host, --network=host, added capabilities and host bind mounts deliberately remove parts of the boundary.
  • For code you don't trust, put another kernel in the way: gVisor intercepts system calls in a user-space kernel, and Kata Containers or Firecracker run each workload in a lightweight VM.

The question you are really asking

Sooner or later someone wants to run code they didn’t write in a container: a CI job from a pull request, a customer’s plugin, a script an AI agent produced. The question is whether the container is a wall or a curtain.

The honest answer is that it is a set of good locks on doors that all open into the same building. To know which threats it stops, you need to know exactly what Docker puts around a process, and what it can’t.

What a default container gets

The kernel features are the subject of the Linux lessons on namespaces, cgroups and capabilities. Here is how Docker combines them. I read the defaults from Moby’s source (daemon/pkg/oci/defaults.go and its seccomp profile) rather than from memory:

  • Namespaces: mount, network, PID, IPC and UTS, plus a cgroup namespace on cgroup v2 hosts. Engine 29.5 (May 2026) added a private time namespace by default on kernels that support it. There is no user namespace by default, so root in the container is UID 0 on the host.
  • Capabilities: 14 of root’s 41, such as CAP_CHOWN, CAP_NET_BIND_SERVICE and CAP_SETUID. Notably absent: CAP_SYS_ADMIN, CAP_SYS_MODULE, CAP_SYS_PTRACE.
  • Seccomp: a filter on system calls. The default action is to return EPERM. The profile allows 361 calls unconditionally and a few dozen more only when a matching capability is present. mount, unshare and setns need CAP_SYS_ADMIN. keyctl, add_key, kexec_load, userfaultfd and the io_uring calls are not allowed at all.
  • /proc and /sys: paths such as /proc/kcore, /proc/keys and /proc/sched_debug are masked, and /proc/sys, /proc/irq and others are read-only.
  • LSM: the docker-default AppArmor profile on Debian and Ubuntu hosts, or SELinux labels on Fedora and RHEL when the daemon enables SELinux.
  • Devices and resources: a minimal /dev, a device cgroup, and whatever cgroup limits you set.

Each layer exists because the one beneath it leaks. The kernel keyring isn’t namespaced, so seccomp blocks the keyring calls. Root in the container is real root, so most of its capabilities are dropped.

The one thing they all share

Every container on a host talks to the same kernel. A process in a container calls read, socket, mmap just like any other process, and the host kernel runs that code. Namespaces change what the process can see. They don’t change which kernel code it can reach.

So a kernel bug reachable through an allowed system call is a potential escape. This is not hypothetical. In 2026 a privilege escalation in the kernel’s crypto socket interface, CVE-2026-31431, nicknamed “Copy Fail”, was reachable from inside containers. Docker 29.4.2 responded by blocking AF_ALG sockets in its default seccomp profile, and 29.4.3 moved the block to AppArmor and SELinux rules after the first fix broke 32-bit programs. In the current profile, socket is allowed only for a list of address families, and 38 (AF_ALG) is not among them. Seccomp bought time until hosts were patched. It cannot do that for every future bug.

The runtime that sets up the container is code too. runc’s security advisories include CVE-2024-21626 (“Leaky Vessels”, a leaked file descriptor that let a crafted image reach the host filesystem), three high-severity escapes published together in November 2025 (CVE-2025-31133, CVE-2025-52565, CVE-2025-52881), and CVE-2026-119101 this month. Keeping Docker, containerd and runc patched is part of isolation.

Moby’s threat model, the document that decides what Docker treats as a vulnerability, states the limit directly. It lists “the shared-kernel container model itself” as out of scope and says “stronger isolation needs a VM-based runtime”.

How people weaken it by accident

Every default above can be switched off, and some popular flags do several at once:

docker run --privileged ...          # all capabilities, all devices, no seccomp or AppArmor
docker run --pid=host ...            # sees and can signal every host process
docker run --network=host ...        # shares the host's network stack and ports
docker run --cap-add SYS_ADMIN ...   # mount, unshare, setns become available
docker run -v /:/host ...            # the host filesystem, read-write
docker run -v /var/run/docker.sock:/var/run/docker.sock ...   # see the next lesson

The threat model puts it bluntly: bind-mounting any host path changes the isolation boundary, even read-only. When you review a Compose file or a docker run line from the internet, these are the words to search for.

Stronger boundaries

When the code is genuinely untrusted, add a second kernel between it and the host.

  • gVisor (runsc) is an OCI runtime that runs a kernel written in Go in user space. The container’s system calls go to that kernel, which uses a much smaller set of host calls to do its work. Install it and run docker run --runtime=runsc .... The cost is system-call-heavy performance and some compatibility gaps.
  • Kata Containers and Firecracker run each container or pod inside a lightweight virtual machine with its own guest kernel. A kernel exploit lands in the guest. The cost is a VM’s boot time and memory, small with Firecracker but not zero.
  • Docker Desktop already runs the engine inside a Linux VM, so an escape on a laptop lands in that VM rather than in macOS or Windows. That protects the laptop, not other containers in the same VM.

A practical rule of thumb: your own services, built by your pipeline, run fine as hardened ordinary containers. Code from strangers gets a VM boundary.

The next lessons tighten the ordinary container: the Docker socket, running as non-root, and capabilities, seccomp and read-only containers.

About the video

The embed is all of Cloud Codes’ “Which Sandbox Can Actually Hold an AI Agent? (Docker, gVisor, Firecracker)”, October 2026, 12 minutes 44 seconds. The AI-agent framing is just the hook. The chapters cover the container escape problem and runc CVEs, “who answers the syscall” as the real test of isolation, the shared kernel, the Leaky Vessels breakouts, gVisor and how far it shrinks the host system-call surface, Firecracker microVMs, Docker Desktop’s VM, and a decision matrix. That is this lesson’s argument almost exactly. It is a small, newer channel, and the narration may be synthetic. YouTube reports no audio language, so English was judged from the title, description and English caption track. It does not list Docker’s actual defaults, which the lesson takes from Moby’s source. Liz Rice’s interview in deeper is the same idea from the author of Container Security.

What was run: Moby’s default OCI spec, capability list and vendored seccomp profile were read from the source and the profile was analysed with a short Python script (361 unconditional allows, the capability-gated calls, the socket families). runc’s advisories were listed from GitHub’s API. No containers were run, since no daemon was available. Release details are from the Docker Engine 29 release notes, checked 2026-11-28.

Where this fits

The biggest hole in most setups isn’t in the kernel at all. It is a socket many people mount without thinking: the Docker socket is root.

Check yourself

  1. 01A colleague says containers are safe for running customers' arbitrary code because each one has its own PID and network namespace. What is missing from that argument?

    All containers share the host kernel. Namespaces change what a process can see, not which kernel code it can reach, so a kernel bug in an allowed system call can lead to an escape. Untrusted code needs a stronger boundary such as gVisor or a microVM.

  2. 02Docker's default seccomp profile refuses keyctl and add_key. Why block those in particular?

    The kernel keyring is not namespaced, so a container could read or affect keys belonging to the host or other containers. Blocking the calls removes that shared surface.

  3. 03In May 2026 Docker 29.4.2 blocked AF_ALG sockets in its default seccomp profile. What does that tell you about where container security comes from?

    The kernel had a privilege escalation bug reachable from inside containers (CVE-2026-31431). Seccomp shrinks which kernel code a container can reach, so it can blunt kernel bugs before the kernel is patched.

  4. 04Which four docker run flags each remove a different part of the default isolation?

    For example --privileged (all capabilities and devices, no seccomp), --pid=host (host process table), --network=host (host network stack) and -v /:/host (the host filesystem). --cap-add SYS_ADMIN is another.

Go deeper

Notes

Private to you

Esc
↑↓ navigate↵ open? shortcuts

Keyboard shortcuts

Press Esc to close

Anywhere

⌘K
Search and commands
/
Search
?
This sheet
Esc
Close

Reading a lesson

J
Next lesson
K
Previous lesson
B
Bookmark