Skip to main content

Docker Engine

The Docker integration reads a Docker Engine, or a whole Swarm through any one of its managers, through the Docker Engine API. It runs on an Integrator inside your network.

It is read-only. The integration never starts, stops, pulls or reconfigures anything.

What it collects​

SyncCollects
Host discoveryThe engine host with its Docker version, OS, kernel, CPU and memory; through a Swarm manager, the swarm and every node with its role, state and address
Container discoveryEvery container with its image, addresses, MACs, state and labels; Swarm services with their running task count; the image store with registries, repositories and tags
Service discoveryEvery port a container or Swarm service publishes on the host, tied to the container or service behind it

Containers appear under Compute > Containers next to those from every other platform, and images under Compute > Registries. A published port is recorded with the host address it answers on: a Swarm ingress port answers on every node of the swarm, and a port bound to the host's loopback address is not published to the network and is left out.

An engine outside a swarm, or a Swarm worker, reports itself and its own containers. A Swarm manager reports the whole swarm.

Create a client certificate​

The Engine API has no read-only role: a client certificate the daemon accepts can do anything the docker command can. Keep the certificate and key to the Integrator, and use a dedicated CA for them so they can be revoked by removing it. To limit what the certificate can do, run an authorization plugin that allows GET requests only.

  1. Create a CA and a server certificate for the daemon, if it does not already serve TLS, then enable the TLS remote API in /etc/docker/daemon.json:

    {
    "hosts": ["unix:///var/run/docker.sock", "tcp://0.0.0.0:2376"],
    "tlsverify": true,
    "tlscacert": "/etc/docker/certs/ca.pem",
    "tlscert": "/etc/docker/certs/server-cert.pem",
    "tlskey": "/etc/docker/certs/server-key.pem"
    }

    On a systemd host, the unit's ExecStart must not also pass -H, or the daemon refuses to start. Restart the daemon afterwards.

  2. Generate a key and certificate for the integration, signed by that CA:

    openssl genrsa -out inventory-key.pem 4096
    openssl req -new -key inventory-key.pem -subj "/CN=inventory" -out inventory.csr
    echo "extendedKeyUsage = clientAuth" > inventory.cnf
    openssl x509 -req -days 365 -sha256 -in inventory.csr -CA ca.pem -CAkey ca-key.pem \
    -CAcreateserial -extfile inventory.cnf -out inventory-cert.pem
  3. Allow the Integrator to reach the host on port 2376, and no one else.

In a swarm, do this on one manager: the integration reads the whole swarm through it.

Connect it​

  1. Under Integrations, add Docker Engine with the host's hostname or IP (a Swarm manager for a swarm), the certificate (inventory-cert.pem) and its private key (inventory-key.pem). The port is 2376 unless the daemon listens elsewhere.
  2. In the integration's settings, assign the Integrator that can reach the host.
  3. Enable the syncs you want.

The daemon serves the certificate you issued it. The first connection records the certificate's fingerprint and later connections must present the same certificate. After replacing it, clear the pinned fingerprint in the integration's settings.

A certificate the daemon's CA did not sign fails the sync with an error. It does not report an empty host.