-
Notifications
You must be signed in to change notification settings - Fork 2
Docker Tracker
When enabled with --docker, Knightwatch connects to the Docker daemon and tracks all containers in real time, exposing snapshots via the /docker family of endpoints. It also emits lifecycle events to the Telegram bot and webhook dispatcher.
knightwatch --docker| Endpoint | Description |
|---|---|
GET /docker-containers |
List snapshots of all currently tracked containers |
GET /container/<id_or_name> |
Full snapshot of a single container by ID or name, or 404 if not found |
GET /top-containers |
Top N containers sorted by CPU or memory (requires --docker) |
GET /top-containers?sort=cpu&limit=10
The sort parameter accepts cpu or memory. limit defaults to all containers if omitted.
When the server is started with --allow-docker-commands, the following write endpoints become available. These endpoints are not read-only β they actively affect running containers.
Authentication required. All container command endpoints always require authentication, regardless of whether
--enable-authis set. The auth session endpoints are automatically enabled alongside--allow-docker-commands.
knightwatch --docker --allow-docker-commands| Endpoint | Description |
|---|---|
POST /docker/stop-container |
Stop a container, with an optional timeout before killing it |
POST /docker/kill-container |
Send a signal to a container |
POST /docker/start-container |
Start a container |
POST /docker/restart-container |
Restart a container, with an optional timeout |
POST /docker/pause-container |
Pause (freeze) a container |
POST /docker/unpause-container |
Resume a paused container |
POST /docker/poll/pause |
Pause the polling loop |
POST /docker/poll/resume |
Resume the polling loop |
POST /docker/poll/interval |
Change the polling interval |
Stops a container gracefully, with an optional timeout in seconds before it is forcefully killed:
POST /docker/stop-container
Content-Type: application/json
{ "id_or_name": "my-container", "timeout_secs": 10 }Sends a signal to a container by ID or name:
POST /docker/kill-container
Content-Type: application/json
{ "id_or_name": "my-container", "signal": "SIGKILL" }Start a stopped container:
POST /docker/start-container
Content-Type: application/json
{ "id_or_name": "my-container" }Restart a running or stopped container, with an optional pre-kill timeout:
POST /docker/restart-container
Content-Type: application/json
{ "id_or_name": "my-container", "timeout_secs": 5 }Freeze all processes in a container:
POST /docker/pause-container
Content-Type: application/json
{ "id_or_name": "my-container" }Resume a paused container:
POST /docker/unpause-container
Content-Type: application/json
{ "id_or_name": "my-container" }Pause snapshot collection (the tracker still responds to queries and commands):
POST /docker/poll/pauseResume at the current interval:
POST /docker/poll/resumeChange the polling interval (takes effect immediately):
POST /docker/poll/interval
Content-Type: application/json
{ "interval_ms": 2000 }| Event | Description | Key data fields |
|---|---|---|
docker.initial_snapshot |
First capture after startup |
container_count, containers
|
docker.containers_appeared |
New containers detected |
container_count, containers
|
docker.containers_disappeared |
Containers no longer visible |
container_count, containers
|
docker.container_status_changed |
A container's status changed |
id, name, image, status, previous_status
|
docker.container_health_changed |
A container's health status changed |
id, name, image, health, previous_health
|
docker.container_oom_killed |
A container was killed by the OOM killer |
id, name
|
docker.container_action_result |
Result of a stop/kill/start/restart/pause/unpause command |
id, name, action, success
|
- π³ Docker Started β initial container list and count on startup
- π Containers Appeared β new containers detected
- π» Containers Disappeared β containers no longer visible to the tracker
- π Container Status Changed β previous and current status for a container
- π₯ Container Health Changed β previous and current health state for a container
- π₯ Container OOM Killed β a container was terminated by the out-of-memory killer
- β
/ β Container Action Result β success or failure of a command (stop, kill, start, restart, pause, unpause)
When
--allow-docker-commandsis enabled, the Telegram bot also supports container commands. Authentication is always required for these commands, even via Telegram.