Introduction
Good security relies on layers, and Docker builds its security posture on a combination of well-established Linux kernel technologies, each configured with moderately protective defaults out of the box. These layers include kernel namespaces, control groups, capabilities, mandatory access control, and seccomp.
Kernel Namespaces
Namespaces are the core technology behind containers. Unlike hypervisors, which virtualize physical hardware like CPUs and disks to create virtual machines, namespaces virtualize operating system constructs — process trees, filesystems, and network interfaces — to create what looks and behaves like a regular, isolated operating system.
Every container gets its own instance of six namespace types:
Process ID (pid)— gives each container its own isolated process tree, starting at PID 1Network (net)— provides an isolated network stack, including its own interfaces and IP addressesMount (mnt)— gives each container its own isolated root filesystemInter-process Communication (ipc)— isolates shared memory accessUser (user)— allows container users to be mapped to different users on the hostUTS (uts)— gives each container its own hostname
Namespaces provide lightweight isolation, but on their own they don't constitute a strong security boundary — which is why Docker layers additional technologies on top.
Control Groups
While namespaces handle isolation, control groups (cgroups) handle resource limits. Containers on the same host share underlying resources like CPU, RAM, and disk I/O, much like hotel rooms sharing water and electricity supplies. Cgroups prevent any single container from monopolizing these shared resources and potentially causing a denial-of-service situation for others on the same host.
Capabilities
Running containers as the Linux root user is risky, but non-root users are often too restricted to be practical. Capabilities solve this by breaking root's permissions into a long list of individually grantable powers — such as CAP_NET_BIND_SERVICE for binding to low-numbered ports, or CAP_CHOWN for changing file ownership.
Docker can start a container as root, strip away all capabilities, and add back only the specific ones it actually needs — a practical implementation of the principle of least privilege. Docker ships with sensible default capabilities, though production environments often benefit from further customization.
Mandatory Access Control
Docker integrates with major Linux Mandatory Access Control (MAC) systems such as AppArmor and SELinux, applying a default profile to every new container depending on the host's distribution. These defaults aim for moderate protection without breaking application compatibility, though custom policies can be defined for stricter environments.
Seccomp
seccomp restricts which syscalls — the mechanism applications use to request actions from the kernel — a container is allowed to make. Out of Linux's 300-plus syscalls, Docker's default profile disables roughly 40 to 50 of the more dangerous ones, again balancing security with broad compatibility. Custom seccomp profiles are possible but can be complex to configure correctly given the size of the syscall table.
Conclusion
Together, namespaces, cgroups, capabilities, MAC systems, and seccomp form a layered defense-in-depth security posture for every container Docker runs. None of these technologies alone provides complete security, but their combination — backed by sensible, tested defaults — gives Docker a reasonably strong security baseline with minimal configuration effort.