Skip to content
statance
MenuClose

Monitor Docker hosts with a single container

Run the agent as a container with the host’s /proc, /sys and root filesystem mounted read-only. It reports the host’s metrics — not the container’s — so you see the real picture of the machine your containers share.

What to monitor on Docker

  • 01Host CPU and loadOne container can starve all the others; host-level CPU shows it.
  • 02Host memoryContainers without memory limits can push the host into OOM.
  • 03/var/lib/docker disk usageImages, build cache and container logs fill disks silently. Run docker system prune before it bites.
  • 04ProcessesContainer processes appear in the host process list with their names.

Set it up

  1. Start the agent container

    --pid host and the read-only mounts let it see host metrics.

    docker run -d --name statance-agent --restart unless-stopped --pid host --network host --uts host \ -v /proc:/host/proc:ro -v /sys:/host/sys:ro -v /:/host/root:ro -v /var/run/docker.sock:/var/run/docker.sock:ro \ -e STATANCE_KEY=YOUR_API_KEY alpine:3.20 sh -c "wget -qO- https://statance.com/agent/container.sh | sh"
  2. Or use Compose

    Add it as a service in docker-compose.yml with the same mounts and STATANCE_KEY env var.

  3. Check logs

    docker logs statance-agent

Recommended alerts for Docker

  • Server stopped reporting for 5 minutes (down)
  • CPU above 90% for 10 minutes
  • Memory used above 90% for 5 minutes
  • Any disk above 85% used
  • /var/lib/docker volume above 80%

Docker FAQ

Does it report per-container CPU and memory?

Yes. With the Docker socket mounted (as in the command above) the agent reports each container’s status, CPU, memory and network every 5 minutes. Leave the socket mount out if you only want host metrics.

Why does it need --pid host?

Without the host PID namespace the process list would only show the agent itself.

Can I monitor the apps inside my containers too?

Yes — add HTTP or TCP monitors for the ports your containers expose, and heartbeat monitors for scheduled jobs.

Uptime monitoring with super powers.