Skip to main content

Docker Monitoring

This guide explains how to monitor your Docker Engine using Harbor Lighthouse. The agent connects directly to the local Docker daemon to stream real-time host-level statistics, including container state counts, system resource limits, and Swarm status.

Repo Link: https://github.com/harborscale/harbor-lighthouse

Prerequisites

Before starting, ensure you have:

  • Docker Engine installed and running on the host.
  • Harbor Lighthouse installed (See Installation Guide).
  • Root or Docker Group permissions for the user running the agent.

How it Works

Unlike other solutions that deploy a "sidecar" container, Lighthouse runs as a lightweight binary on the host system. It communicates with the Docker Engine via the Unix socket (/var/run/docker.sock on Linux) or named pipe (on Windows).

Note on Performance: The collector uses connection pooling to reuse the Docker client connection and explicitly disables heavy per-container disk usage calculations, ensuring minimal impact on your system even with hundreds of containers.


Setup Guide

1. Configure Permissions (Linux/macOS)

To allow Lighthouse to read Docker stats, the user running the agent (usually your current user or root) must have access to the Docker socket.

If you are running Lighthouse as a specific user, add them to the docker group:

sudo usermod -aG docker $USER

Note: You may need to log out and log back in (or restart the service) for these permissions to take effect.

Windows: Run PowerShell as Administrator when installing and running Lighthouse.

2. Add the Monitor

Use the lighthouse CLI to enable the Docker collector.

For Harbor Scale Cloud (Linux/macOS):

sudo lighthouse --add --name "docker-host-01" --harbor-id "YOUR_HARBOR_ID" --key "YOUR_API_KEY" --source docker

For Harbor Scale Cloud (Windows):

lighthouse --add --name "docker-host-01" --harbor-id "YOUR_HARBOR_ID" --key "YOUR_API_KEY" --source docker

Configuration

You can customize the Docker monitor using standard Lighthouse flags.

FlagDescriptionDefault
--intervalHow often to poll engine stats (in seconds).60
--nameThe unique ID/Name for this Docker Host.(Required)
--sourceMust be set to docker.-

Available Metrics

The docker source collects Engine-level metrics. It aggregates the states of all containers on the host rather than streaming stats for individual containers.

Container Aggregates

MetricDescription
Total ContainersTotal number of containers on the host.
RunningNumber of containers in running state.
Exited/StoppedNumber of containers in exited state.
PausedNumber of paused containers.
Error/DeadNumber of containers in dead or restarting states.

Engine & System Resources

MetricDescription
ImagesTotal number of images stored locally.
VolumesTotal number of local Docker volumes.
GoroutinesNumber of internal Docker goroutines (useful for debugging daemon load).
CPUsNumber of CPUs available to the Docker Engine.
Total MemoryTotal memory available to the Docker Engine.
File DescriptorsNumber of open file descriptors used by the daemon.

Swarm Mode

If the engine is part of a Swarm, the following metrics are populated:

MetricDescription
Swarm StateNumeric status: 0 (Inactive), 1 (Pending), 2 (Active), 3 (Error).
ManagersNumber of Swarm managers.
NodesTotal number of nodes in the Swarm.

Troubleshooting

Common Issues

"Permission denied: /var/run/docker.sock" (Linux/macOS)

  • Cause: The Lighthouse agent does not have permission to talk to the Docker Daemon.
  • Fix: Ensure the user running the process is in the docker group (see Step 1 above), or run Lighthouse with sudo.

"docker_client_init_error"

  • Cause: The agent cannot connect to the Docker API.
  • Fix: Check if Docker is running (docker info). If Docker was just restarted, the agent will automatically attempt to reconnect on the next interval.

No data appearing

  • Check the agent logs:
lighthouse --logs "docker-host-01"
  • If you see metrics like docker_containers_total, the connection is successful.