Checks / Network

The Docker API listens on TCP

Check
net.docker_api_tcp
Severity
critical
Runs
on the server, in the daily run of the agent
Looks at
TCP sockets of dockerd, -H tcp:// in the service files, tcp:// in the hosts of daemon.json
Updated 26 Nov 2026

What the check looks at

The TCP sockets of dockerd, the hosts entry of /etc/docker/daemon.json, and -H tcp:// or --host tcp:// options in /etc/default/docker, /etc/sysconfig/docker and the docker.service unit with its drop-ins. The check fails for a TCP address on the network and warns for one on loopback. The evidence names the kind of address (0.0.0.0, ipv4-public) and the port.

Risk

The Docker API can start a container with the root directory of the host mounted. Over TCP without TLS client certificates (port 2375 by convention, 2376 with TLS), any client that reaches the port can do that with one HTTP request. Docker deprecated TCP without TLS in Engine 26.0, but Docker Engine 29.9.2 still starts with such a listener. In a test it logged a deprecation notice, delayed its start by 16 seconds and then answered API requests without authentication. With TLS, every holder of a client certificate is still root on the host.

How to fix it

  1. Find where the TCP address comes from:

    ps -o args= -C dockerd
    systemctl cat docker.service      # systemd: look at ExecStart and the drop-ins
    grep -s hosts /etc/docker/daemon.json
    

    On Alpine, also look at DOCKER_OPTS in /etc/conf.d/docker.

  2. Remove the -H tcp://... option or the tcp:// entry in hosts. Keep -H fd:// (the systemd units of the Docker packages) or the Unix socket.

  3. Restart Docker. This stops the running containers unless live-restore is on in daemon.json:

    sudo systemctl daemon-reload && sudo systemctl restart docker   # systemd
    sudo rc-service docker restart                                  # Alpine (OpenRC)
    
  4. For remote administration, use SSH:

    docker context create prod --docker host=ssh://deploy@203.0.113.10
    docker --context prod ps
    

If you need TCP, use TLS with client certificates on port 2376 (--tlsverify, --tlscacert, --tlscert, --tlskey), and in the firewall allow the port only from known addresses.

How to check the fix

sudo ss -tlnp | grep dockerd

The output must be empty. From another machine, nc -zv -w 3 <server> 2375 must fail.

When a warning is fine

A TLS listener with client certificates, behind a firewall that allows only a management host, can be a deliberate setup; guard the certificates like root SSH keys. A plain listener on 127.0.0.1 cannot be reached from the network, but every local user and process can use it, also those outside the docker group. A plain listener on a public or private network address is never fine.

Sources