Skip to content
Securityintermediate

What is Docker security?

Updated Nov 30, 20263 min readBased on official documentation
What is Docker security?

In short

Docker security is the set of protections that keep containers from harming the host or each other. It rests on kernel namespaces and control groups for isolation, a locked-down Docker daemon, restricted Linux capabilities, and optional image signing. Knowing these four areas helps you run containers safely.

Docker runs applications in containers. A container is an isolated process with its own view of files, network and resources. Docker security asks how strong that isolation is, and where it can break. The official documentation groups the topic into four areas: the kernel features that isolate containers, the attack surface of the Docker daemon, weak spots in container configuration, and kernel hardening features that work alongside containers.

Isolation from the kernel

Docker containers rely on two Linux kernel features. The first is namespaces. When you start a container, Docker creates a set of namespaces for it. Processes in one container cannot see processes in another container or on the host. Each container also gets its own network stack, so it does not get direct access to another container's sockets or interfaces.

Containers on the same host can still talk to each other over the network if you publish ports or link them. They can ping each other, exchange UDP packets and open TCP connections. You can restrict this traffic when you need to. By default, containers on one host sit on bridge interfaces, which works much like machines plugged into the same network switch.

The second feature is control groups, often called cgroups. They limit and measure how much memory, CPU and disk I/O each container uses. Cgroups do not stop one container from reading another container's data. Their job is to stop a single container from exhausting resources and taking the whole machine down. This matters most on shared platforms where many applications run side by side.

The Docker daemon is a sensitive target

The Docker daemon, called dockerd, normally runs with root privileges. Anyone who can control the daemon can control the host. Only trusted users should be allowed to talk to it.

Docker can share a host directory with a container without limiting what the container can do with it. If a container mounts the host root directory, it can change any file on the host. Be careful if a web service creates containers from user input through an API. Check every parameter so that attackers cannot request arbitrary containers.

By default the Docker command-line tool talks to the daemon through a Unix socket, not a network port. You can control access to that socket with normal file permissions. If you expose the API over HTTP, secure it with HTTPS and certificates. The documentation says the daemon refuses to start with an unauthenticated TCP setup. Using SSH to reach the daemon is another option. Keep the server dedicated to Docker, and run other services inside containers where possible.

Linux capabilities reduce what root can do

Linux capabilities split the all-or-nothing root user into smaller permissions. A web server that only needs to bind to a port below 1024 can receive that one capability instead of full root rights. Most application containers do not need real root at all. Tasks like SSH access, log handling and network setup are usually handled outside the container.

By default, Docker starts containers with a restricted set of capabilities. It follows an allowlist approach: only the capabilities it considers necessary are kept. Operators can add or remove capabilities. Removing more makes a container safer. Adding capabilities can weaken it. A good habit is to drop everything the process does not explicitly need. Even if an attacker gains root inside a container, a smaller capability set makes further damage harder.

Image signing with Docker Content Trust

Docker Content Trust verifies image signatures. It is built into the dockerd binary. You can configure the daemon so that it runs only signed images. The setup is done in the daemon configuration file, where you can pin trust to a root key you choose. Only repositories signed with that key can then be pulled. This protects you from tampered or unknown images.

Common mistakes

A frequent mistake is running containers with more privileges than they need. Another is mounting sensitive host paths without a clear reason. Exposing the daemon over an open network port is also dangerous. Finally, many people assume containers are a complete sandbox. They are not. The default setup offers real isolation, but kernel vulnerabilities and loose configuration can weaken it, so review your settings regularly.

FAQ

Is a Docker container as secure as a virtual machine?

Not exactly. Containers share the host kernel, so isolation is provided by kernel namespaces and control groups rather than a separate guest kernel. A virtual machine usually offers a stronger boundary.

Why does the Docker daemon need root?

The daemon creates namespaces, mounts, networks and containers, which require elevated privileges. The documentation notes that it runs as root unless you use Rootless mode.

What is the safest way to reach a remote Docker daemon?

Use HTTPS with certificates, or reach the daemon over SSH. The documentation says plain TCP without TLS is not permitted and causes the daemon to fail on startup.

Do I need to drop capabilities for every container?

It is a good practice. Start from the default set, then remove any capability your process does not need. Adding capabilities should be a deliberate choice.

Sources

This page is based on the official documentation below. Read it for full detail.

Docker security — official documentation ↗
blozhikDeveloper news from across the web, explained. Every story links to its original sources.