Free tech learning for everyone, from basics to pro

Container SecurityCloud SecurityIntermediate

Hardening Docker hosts and daemons: CIS ideas, rootless mode and user namespaces

In short: Containers are only as safe as the host and daemon underneath them. Keep the host minimal and patched, restrict the Docker socket, configure the daemon securely and use rootless mode or user namespace remapping so container root is not host root. The CIS Docker Benchmark is a good checklist.

Why the host matters

All containers on a host share its kernel and are managed by the Docker daemon, which by default runs as root. If an attacker escapes a container, or gains access to the daemon, they usually own the host and every container on it. Hardening the host and daemon limits that blast radius. The CIS Docker Benchmark from the Center for Internet Security is a widely used checklist; the ideas below follow its main themes in plain terms.

Hardening a Docker hostDocker hostshared kernelMinimal OSpatched, fewservicesDaemon configdaemon.jsonRootless modeno root daemonUser namespacesremap rootSocket accesslimit docker groupAudit and logsauditd, central logs
Figure 1. The areas to cover when hardening a host that runs containers.

The host

  • Use a minimal, supported Linux distribution or a container-optimised OS, and patch the kernel promptly.
  • Run only container workloads on the host; avoid mixing in unrelated services.
  • Put Docker data (/var/lib/docker) on its own partition so a full disk from container logs or images does not take down the OS.
  • Enable auditd rules for Docker files and binaries and forward logs centrally. See Linux hardening for general host steps.

The daemon and its socket

Anyone who can talk to the Docker socket can start a privileged container and mount the host filesystem, so membership of the docker group is effectively root. Keep that group small, never expose the daemon on an unauthenticated TCP port, and if remote access is required use SSH or mutual TLS.

{
  "icc": false,
  "live-restore": true,
  "no-new-privileges": true,
  "userns-remap": "default",
  "log-driver": "json-file",
  "log-opts": { "max-size": "10m", "max-file": "3" }
}

This example /etc/docker/daemon.json disables unrestricted traffic between containers on the default bridge, keeps containers running during daemon restarts, blocks privilege escalation by default, enables user namespace remapping and caps log size. Test such changes in a lab first, because some applications depend on the defaults.

Rootless mode and user namespaces

Rootful versus rootless DockerRootful (default)Daemon runs as rootEscape means host rootAll features workdocker group = rootRootlessDaemon runs as a userEscape limited to userSome network limitsPer-user install
Figure 2. Rootless mode trades a few features for a much smaller blast radius if a container escapes.

User namespace remapping (userns-remap) maps UID 0 inside containers to an unprivileged range of UIDs on the host. A process that is root in the container is just an ordinary user outside it. Rootless mode goes further: the daemon itself and all containers run under a normal user account, so even a daemon compromise does not give host root. Podman takes a similar daemonless, rootless-first approach.

dockerd-rootless-setuptool.sh install
systemctl --user enable --now docker
docker context use rootless

Rootless mode has some limits, for example binding to ports below 1024 needs extra configuration and some network and storage drivers behave differently. Check these against your workloads.

A practical checklist

AreaCheck
HostPatched kernel, minimal packages, separate partition for Docker data
AccessSmall docker group, no open TCP socket, admin access via SSH keys
Daemonno-new-privileges, log limits, user namespaces or rootless
ContainersNo --privileged, no socket mounts, resource limits set
MonitoringAudit rules, central logs, regular benchmark scans

Tip: the open-source docker-bench-security script checks a host against many CIS recommendations. Run it on your own lab host to see where you stand.

Practice

Why is adding a user to the docker group a security decision?
Members can control the root-owned daemon, start privileged containers and mount the host filesystem, so it is equivalent to root access.
What does userns-remap change?
It maps root inside containers to an unprivileged UID range on the host, so container root is not host root.
Give one limitation of rootless Docker.
For example, binding to ports below 1024 needs extra setup, and some networking and storage features differ.

Key takeaways

  • A daemon or container escape usually means host compromise.
  • Keep the host minimal, patched and dedicated to containers.
  • Protect the Docker socket; the docker group equals root.
  • Use rootless mode or user namespace remapping.
  • Use the CIS Docker Benchmark and audit tools as a checklist.
Tracks your learning on this device only. See your progress on the learning paths.

About the author

Mohamed Fayas

Founder of FM TecHub. CCNA certified, with a BTEC HND in Network Engineering, and BEng (Hons) in Computer Networking and Cloud Security. He writes practical, plain-English guides on networking, security and cloud.

More about the author

Original content written by Mohamed Fayas for FM TecHub. © 2026 FM TecHub. You're welcome to share a link to this page; please don't copy the text elsewhere without permission.

Stay up to date by email

New notes, tools and security news from FM TecHub, explained simply. Free.

We only use your email to send these updates. See our privacy policy.