Every route to the Docker Engine API is a route to root on the host, and most environments have more of those routes than their owners think. The local Unix socket at /var/run/docker.sock, a TCP listener on 2375 or 2376, a socket mounted into a monitoring container, a CI runner that shares the host daemon: each one hands whoever reaches it the ability to start a privileged container with the host filesystem mounted. This guide is for platform, DevOps and security engineers who need to find and close those routes. It goes deeper than the general Docker and Docker Compose Security Guide on one question: who can talk to the daemon, and how to narrow that to the people and tools that truly need it.
This is an independent guide from NHI Mgmt Group, based on Docker's public documentation as of November 2026. It is not sponsored or reviewed by Docker. Product features change, so confirm settings against Docker's current documentation.
Key takeaways
- API access is host root. Docker's documentation says only trusted users should control the daemon, and OWASP states that giving someone the socket is equivalent to unrestricted root access to the host.
- Read-only mounts do not help. Mounting
docker.sockwith:rostops file writes to the socket inode, not API calls; OWASP is explicit that it does not make the API read-only. - Remote access needs mutual TLS or SSH. Use
--tlsverifywith a private CA and client certificates on 2376, orDOCKER_HOST=ssh://user@host; a daemon started with--tlsalone does not authenticate clients. - If a tool needs the API, give it a filtered view. Authorization plugins and socket proxies let you allow read-only or named API sections; both have documented blind spots you must design around.
- CI is where shared sockets hide. Socket binding in runners lets any pipeline author become host root; prefer ephemeral hosts, per-job daemons or daemonless builders.
Why the Docker socket equals root
The Docker daemon, dockerd, runs as root unless rootless mode is used. Its API has no built-in notion of per-user permissions: Docker's authorization plugin documentation describes the default model as all or nothing, where anyone with access to the daemon can run any command. A client that can call the API can ask for a container with / bind-mounted, the host PID and network namespaces, and every capability. Docker's engine security page warns that such a container can alter the host filesystem without restriction.
Docker's post-install documentation warns that the docker group, which can use the local socket, grants root-level privileges. So "who is root on this host" includes every route in the table below.
| Exposure | Who can reach it | Authentication | Risk level | Preferred fix |
|---|---|---|---|---|
Local socket, docker group | Group members on the host | Unix file permissions only | High on shared hosts | Minimal group membership, rootless mode for users, sudo for admin tasks |
| Socket bind-mounted into a container | Any process in that container, and anyone who compromises it | None beyond reaching the container | Critical | Remove the mount; if unavoidable, filtered proxy or authorization plugin |
| TCP 2375 (plain HTTP) | Anyone with network reach, including other containers | None | Critical, especially if internet-facing | Remove the listener; Docker's security page says the daemon now refuses to start this way, but older engines may not |
TCP 2376 with --tls only | Anyone with network reach | Server certificate only, clients not verified | Critical | Switch to --tlsverify with client certificates |
TCP 2376 with --tlsverify | Holders of a client certificate signed by the daemon's CA | Mutual TLS | Moderate: every certificate holder is root | Private CA per environment, short-lived certificates, management network only |
SSH (ssh://user@host) | Users with SSH access who can reach the socket | SSH keys or certificates | Moderate: same as local socket access | Central SSH certificate issuance, MFA on the bastion, audited sessions |
Remote API exposure
Docker's remote access page warns that accepting remote connections can leave the host open to unauthorised access, and that without securing the connection, remote non-root users can gain root on the host. The default ports are 2376 with TLS and 2375 without. Two configuration paths enable a TCP listener, and Docker notes that using both causes a conflict that stops the daemon from starting:
- daemon.json: a
hostsarray in/etc/docker/daemon.json, for example the Unix socket plus a TCP address. Not supported on Docker Desktop for Windows or Mac. - systemd override:
systemctl edit docker.servicewith a replacementExecStart=line carrying-Hflags.
Audit both. Docker's engine security page now states that exposing the daemon API over HTTP without TLS is not permitted and that the daemon fails early on startup in that configuration, while the remote access page still says remote access without TLS is not recommended and will require explicit opt-in in a future release. Read the two pages together as a change in progress: do not assume every engine blocks plain HTTP, because long-lived servers and images pinned to older releases may still accept it. Check the engine version on every host.
Firewalls alone are not a fix. The engine security page notes that containers can often still reach an API endpoint protected only by a host firewall, which leads straight to privilege escalation.
For most teams the answer is no TCP listener at all: administrators can use docker context create --docker host=ssh://USER@HOST, which keeps one access path (SSH) to govern instead of two.
Socket mounts in containers and CI
Socket mounts are the most common exposure because many tools ask for one: reverse proxies, log shippers, monitoring agents and CI agents. Each such container becomes a host-root asset.
Finding socket mounts
- Running containers: list every container's mounts with
docker inspectand search theSourcefield fordocker.sock,containerd.sockor the rootless socket under/run/user/. - Compose and stack files: search repositories for
/var/run/docker.sockand//./pipe/docker_engine(the Windows named pipe). - Kubernetes: search manifests and the live cluster for
hostPathvolumes pointing at runtime sockets. The Pod Security Standards Baseline profile forbids hostPath volumes, so enforcing Baseline or Restricted at namespace level blocks this class of mount outright.
CI runner patterns
GitLab's documentation describes the trade-offs clearly. Socket binding avoids privileged mode but, in GitLab's words, effectively disables the container's security mechanisms and exposes the host to privilege escalation. Docker-in-Docker gives each job its own daemon but requires privileged mode on the runner.
| Pattern | Isolation between jobs | Host exposure | Choose when |
|---|---|---|---|
| Host socket bound into job containers | None: jobs share one daemon and see each other's containers | Any pipeline author can gain host root | Avoid on any runner that accepts code from more than one trusted team |
| Docker-in-Docker service (privileged) | Separate daemon per job | Privileged container on the runner host | Ephemeral runner VMs destroyed after each job |
| Rootless BuildKit or Buildah | Per job, no daemon | No root daemon; runs as an ordinary user | Image builds on shared or Kubernetes runners |
| Ephemeral VM per job with a local daemon | Full VM boundary | Contained to a throwaway VM | Untrusted or fork-based pipelines, regulated builds |
See the Self-hosted CI/CD Runners and Build Agents guide for runner isolation and registration token handling.
TLS and authorisation plugins
Mutual TLS done properly
Docker's "Protect the Docker daemon socket" page sets out the model. Create a private CA (ca.pem, ca-key.pem). Issue the server a certificate with extendedKeyUsage = serverAuth and subjectAltName entries for every DNS name and IP clients will use. Issue each client a certificate with extendedKeyUsage = clientAuth. Start the daemon with --tlsverify --tlscacert --tlscert --tlskey and -H=0.0.0.0:2376, or better, bind to a management interface address. Clients use DOCKER_HOST=tcp://host:2376 and DOCKER_TLS_VERIFY=1, with certificates in ~/.docker or DOCKER_CERT_PATH.
- Only
--tlsverifyauthenticates clients. Docker's page distinguishestlsverify, which authenticates clients, fromtlswith a server certificate only, which does not. - Protect the keys like root passwords. Docker's page tells readers to guard client keys as they would a root password, and warns that with a default
umaskof 022 the generated keys are world-readable; it recommendschmod 0400for keys and0444for certificates. - Use a dedicated CA with short lifetimes. Any client certificate the CA signed is accepted, so never reuse a corporate CA; short lifetimes and CA rotation are the practical revocation method.
Authorization plugins
Authorization plugins add the per-request control the daemon lacks. The daemon passes each API request to the plugins named with --authorization-plugin; a chain of plugins must all allow a request, and a plugin error or Allow: false denies it, so the design fails closed. With TLS, the user identity passed to the plugin is the client certificate's common name, which lets you write rules such as "the monitoring identity may only call GET endpoints". Docker's documentation lists limits you must design around:
- gRPC is not covered: native gRPC calls and those upgraded through
POST /grpcare not authorised by plugins. - Bodies only for JSON: request and response bodies are forwarded only with
Content-Type: application/json. - Streams are checked once: for hijacked connections such as
exec, only the initial request is evaluated, not the streamed data. - Parsing must match the daemon: plugins must decode bodies exactly as the daemon does, or they may judge a different request from the one executed.
- Response inspection is capped: buffering stops at 64 KiB, so do not base security decisions on response bodies.
Socket proxies
A socket proxy sits between a tool and the socket and blocks API paths by prefix. The widely used open source docker-socket-proxy project, for example, is an HAProxy configuration that returns HTTP 403 for disallowed sections: EVENTS, PING and VERSION are allowed by default, security-critical sections such as AUTH, SECRETS and all POST requests are refused by default, and everything else (CONTAINERS, EXEC, IMAGES and so on) is opt-in. Its own README warns that the proxy port must never be exposed to a public network, only to a Docker network shared with the consuming service, and that it serves plain HTTP. The proxy container itself still holds the real socket, so keep it minimal and patched.
Rootless mode and alternatives
The controls above narrow who can call the API. Rootless mode reduces what a successful call is worth. Docker's rootless documentation describes running both the daemon and containers inside a user namespace, unlike userns-remap, where the daemon itself still runs as root. Prerequisites are the newuidmap and newgidmap binaries (usually the uidmap package) and at least 65,536 subordinate UIDs and GIDs in /etc/subuid and /etc/subgid. Installation is dockerd-rootless-setuptool.sh install as the target user, and clients connect with a per-user socket such as DOCKER_HOST=unix:///run/user/1000/docker.sock.
Rootless suits developer workstations, CI runners and multi-user build hosts; test production hosts that need privileged ports or host networking before switching. OWASP's Docker cheat sheet notes that rootless mode does not protect against kernel vulnerabilities, so keep the host kernel patched and keep seccomp and AppArmor or SELinux profiles in place.
Decision guidance
- Single-purpose production host, no remote management: rootful daemon, socket only,
dockergroup empty, admins use sudo over SSH. - Fleet managed from a central tool: SSH contexts or mutual TLS on a management network, plus an authorization plugin so the tool's identity can only do what it needs.
- Tool that only reads container metadata: socket proxy with
POST=0and only the needed sections, on an internal Docker network. - Shared developer or CI hosts: rootless per user or per runner, or move to daemonless builders.
- Small teams: removing TCP listeners and socket mounts closes most of the risk; large estates add plugins, central certificate issuance and scanning.
Where identity fits
Every party that can reach the daemon is an identity with root-equivalent rights: the human in the docker group, the client certificate on a laptop, the service account of a monitoring agent, the CI job token that can change a pipeline using a socket-bound runner. Put them in your privileged access inventory with an owner and review date, and rotate Docker TLS client keys like other machine credentials. See the CI/CD Pipeline Identity Security Guide for pipeline credentials and the Docker Hub Tokens Security Guide for registry tokens that often sit on the same hosts.
Detection
| What to watch | How | Signal |
|---|---|---|
| TCP listeners on 2375 and 2376 | Authorised internal scans of your own ranges and cloud security group reviews; external attack surface monitoring for your public IPs | Any 2375 response is an incident to fix today; 2376 must require a client certificate |
| Daemon configuration | Configuration management checks on daemon.json hosts, systemd overrides and tlsverify | Drift from the approved baseline |
| Socket mounts | Scheduled docker inspect inventory, repository search, Kubernetes admission policy | New container or manifest mounting a runtime socket |
| Access to the socket file | Linux audit rule watching /var/run/docker.sock and the Docker binaries | Unexpected processes or users calling the API |
| API activity | docker events streamed to the SIEM; authorization plugin decision logs | Containers created with Privileged, host PID or network, or a bind mount of /; exec into containers from unusual clients |
| Group membership | Identity governance review of the docker group on every host | Membership growth, unknown accounts |
Map detections to MITRE ATT&CK: abuse of an exposed API typically shows as T1133 External Remote Services, followed by T1610 Deploy Container, T1613 Container and Resource Discovery and T1611 Escape to Host, with T1496 Resource Hijacking a frequent goal on exposed hosts.
Metrics
- Exposed listeners: number of hosts answering on 2375, target zero; hosts on 2376 without client verification, target zero.
- Socket mounts: count of containers and manifests mounting a runtime socket, each with an approved exception and owner.
- Group size: members of
dockerper host, trending down. - CI coverage: percentage of runners using ephemeral VMs, rootless or daemonless builds instead of socket binding.
- Certificate hygiene: share of Docker client certificates with a recorded owner and expiry under your target lifetime.
Implementation plan
- Inventory: scan for 2375 and 2376, list engine versions, collect daemon configuration, socket mounts and
dockergroup members. - Close the critical items: remove plain TCP listeners and
--tls-only configurations first. Roll back by restoring the previous override file if a dependent tool breaks, then move that tool to SSH or mutual TLS rather than reopening the port. - Triage socket mounts: remove, filter through a proxy, or accept with an owner; test proxies on staging with the tool's normal workflows first.
- Fix CI: pilot rootless BuildKit, Buildah or ephemeral VMs with one team, then retire shared socket-bound runners.
- Add authorisation for remote management: mutual TLS from a dedicated CA, short-lived client certificates and a plugin with per-identity rules, logging decisions before enforcing where the plugin allows.
- Adopt rootless where it fits: developer machines and build hosts first.
- Make it stick: admission policies, configuration management checks, continuous external scanning and the metrics above.
Framework mapping
| Framework | Reference | How it applies |
|---|---|---|
| NIST SP 800-53 Rev 5 | AC-6 Least Privilege | Limit daemon access to identities that need it; filtered access for tools |
| NIST SP 800-53 Rev 5 | CM-7 Least Functionality | No TCP listener unless required |
| NIST SP 800-53 Rev 5 | SC-8 Transmission Confidentiality and Integrity | TLS for any remote API access |
| NIST SP 800-53 Rev 5 | AU-2 Event Logging | Daemon events and socket access logging |
| NIST CSF 2.0 | PR.AA-05, PR.PS-01, DE.CM-01 | Access permissions, configuration baselines, network monitoring for exposed services |
| NIST SP 800-190 | Host OS and orchestrator countermeasures | Container platform hardening context |
| MITRE ATT&CK | T1133, T1610, T1611, T1613, T1496 | Detection coverage for API abuse |
Practitioner checklist
- Scan your own address space for TCP 2375 and 2376 and fix any unauthenticated or
--tls-only daemon. - Check
daemon.jsonand systemd overrides on every host; keep one method, with no TCP host unless approved. - Prefer SSH contexts for remote administration; where TLS is used, require
--tlsverifyand a dedicated CA. - Set key file permissions to
0400and give every client certificate an owner and an expiry. - Inventory every socket mount; remove it, filter it through a proxy or plugin, or record an approved exception.
- Remove socket binding from shared CI runners; use ephemeral VMs, rootless BuildKit or Buildah.
- Enforce Pod Security Standards Baseline or Restricted so workloads cannot mount runtime sockets via hostPath.
- Keep the
dockergroup minimal and review it with your other privileged groups. - Stream
docker eventsand socket audit logs to the SIEM and alert on privileged or host-mount container creation. - Run rootless mode on developer and build hosts, and apply Docker engine security updates promptly.
Standards and references
- Docker: Protect the Docker daemon socket
- Docker: Docker Engine security
- Docker: Configure remote access for Docker daemon
- Docker: Access authorization plugin
- Docker: Rootless mode
- OWASP: Docker Security Cheat Sheet
- GitLab: Use Docker to build Docker images
- NIST: SP 800-190 Application Container Security Guide
Related NHI Mgmt Group resources: Docker and Docker Compose Security Guide · Docker Security Checklist · Container Runtime Security Guide · Self-hosted CI/CD Runners and Build Agents