jorgepb96/statainer
关于
Statainer helps you monitor usage of your Docker containers in an easy way from your browser. Includes advanced filters, charts and notifications support (browser and pushover).
系统与基础设施实测星标增长
- 24小时
- 0
- 7天
- 正在收集历史
- 15天
- 正在收集历史
- 1个月
- 正在收集历史
各周期内的星标净变化,周期相互重叠,并非每日新增。缺失的测量保持空白。星标代表关注度,不代表软件质量。
README.md
原文
statainer
A focused dashboard for container monitoring, safe updates, notifications, and Compose-aware operations.
Overview
statainer is a lightweight web UI for Docker hosts. It combines live container metrics, Compose project grouping, configurable alerts, update discovery, rollback history, and day-to-day container controls in one interface.
It is designed for self-hosted environments where you want fast operational visibility without giving up practical controls.
What It Does Well
Monitoring
- Live CPU, RAM, network I/O, block I/O, uptime, restart count, process count, ports, image, and status visibility.
- Table and chart views for individual containers and top-N comparisons.
- Compose project summaries with grouped container states.
- Optional GPU metrics when NVIDIA tooling is available.
Operations
- Start, stop, and restart containers from the UI.
- Open exposed container endpoints directly from the dashboard.
- Inspect container logs without leaving the app.
- Persist filters, visible columns, chart mode, theme, refresh interval, and layout preferences locally.
Updates
- Detect update-ready containers and Compose stacks.
- Run Quick Update for individual targets.
- Run
Update selectedorUpdate allfrom the Update Manager. - Show blocked stacks with explicit guidance when original Compose files are missing or externally managed.
- Keep a persistent update and rollback history.
Notifications
- CPU, RAM, status, and image update alerts.
- Browser-side notification center with pending event history.
- External delivery through Pushover, Slack, Telegram, Discord, ntfy, and generic webhooks.
Programmatic API
- Optional, admin-enabled REST API protected by scoped, per-key bearer tokens.
- Expose container counts, per-container metrics, host CPU cores and max RAM, and run/stop/restart/update controls — all gated by the scopes you grant each key.
- Tokens are hashed at rest and shown once; keys support optional expiration and reversible pause/delete. See API.md for the full reference.
Screenshots
|
|
|
|
|
|
|
|
Quick Start
Requirements
- Docker
- Docker Compose plugin
- Access to the Docker socket on the host
Start With Docker Compose
git clone https://github.com/Drakonis96/statainer
cd statainer
docker compose up --build -d
Once started, open:
http://localhost:5001
Recommended Production Compose
For reverse-proxy deployments (e.g. behind Nginx / Caddy / Cloudflare Tunnel), uncomment and adjust the hardening variables already present in docker-compose.yml:
services:
statainer:
image: drakonis96/statainer:latest
environment:
AUTH_ENABLED: "true"
AUTH_USER: admin
AUTH_PASSWORD_FILE: /run/secrets/auth_password
APP_ENV: "production"
APP_SECRET_KEY_FILE: /run/secrets/statainer_app_secret
LOGIN_MODE: "page"
SESSION_IDLE_MINUTES: "30"
SESSION_COOKIE_SECURE: "true"
TRUSTED_PROXY_HOPS: "1"
CADVISOR_URL: http://cadvisor:8080
ports:
- "5001:5000"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./data:/app/data
secrets:
- auth_password
- statainer_app_secret
restart: unless-stopped
secrets:
auth_password:
file: ./secrets/auth_password.txt
statainer_app_secret:
file: ./secrets/app_secret.txt
Generate a strong secret with openssl rand -hex 32 > ./secrets/app_secret.txt.
Default Deployment Notes
The bundled docker-compose.yml exposes:
- statainer on
5001 - cAdvisor on
8080
It also mounts:
- Docker socket as read-only
- Local app data into
./data
The users/settings SQLite database lives inside the data directory (/app/data in the
container, configurable with DATA_DIR). Keep the ./data volume mounted to persist
users and settings across updates. When upgrading from an older version that stored the
database at /app/users.db, it is moved into the data directory automatically on first
start, so existing accounts are preserved.
One-Click Deploy
Configuration
Core Environment Variables
| Variable | Purpose | Default |
|---|---|---|
AUTH_ENABLED |
Enables authentication | true |
AUTH_USER |
Admin username | empty |
AUTH_PASSWORD |
Admin password | empty |
AUTH_PASSWORD_FILE |
Password file alternative | empty |
APP_SECRET_KEY |
Session secret | generated if missing outside production |
APP_SECRET_KEY_FILE |
Secret file alternative | empty |
APP_ENV |
Runtime mode. Use production behind a reverse proxy |
development |
REQUIRE_EXPLICIT_SECRET_KEY |
Refuses startup with an ephemeral secret | true in production |
LOGIN_MODE |
Login flow: popup or page |
popup |
APP_VERSION |
Version shown in the UI footer | repository VERSION file (v0.9.21) |
DATA_DIR |
Directory where the users/settings database is created and persisted (point it at a folder, not a file) | /app/data |
DOCKER_SOCKET_URL |
Docker socket URL | unix:///var/run/docker.sock |
CADVISOR_URL |
cAdvisor endpoint | http://cadvisor:8080 |
GPU_METRICS_ENABLED |
Enables GPU collection | true in bundled compose |
SESSION_IDLE_MINUTES |
Inactivity timeout for page sessions | 30 |
SESSION_COOKIE_SECURE |
Marks the session cookie as HTTPS-only | true in production |
TRUSTED_PROXY_HOPS |
Number of trusted proxy hops for forwarded headers | 0 |
LOGIN_RATE_LIMIT_MAX_ATTEMPTS |
Failed login attempts before blocking an IP | 5 |
LOGIN_RATE_LIMIT_WINDOW_SECONDS |
Sliding window (seconds) for the attempt counter | 300 |
Authentication Recommendations
- There are no built-in credentials.
- Set
AUTH_USERand eitherAUTH_PASSWORDorAUTH_PASSWORD_FILEbefore exposing the app. - Set
APP_SECRET_KEYorAPP_SECRET_KEY_FILEto keep sessions stable across restarts. - If you want no authentication, set
AUTH_ENABLED=falseexplicitly.
Reverse Proxy Hardening
For Internet exposure behind Cloudflare and a reverse proxy, set at least:
APP_ENV: "production"
APP_SECRET_KEY_FILE: "/run/secrets/statainer_app_secret"
LOGIN_MODE: "page"
SESSION_IDLE_MINUTES: "30"
SESSION_COOKIE_SECURE: "true"
TRUSTED_PROXY_HOPS: "1"
If your reverse proxy appends to X-Forwarded-For on top of Cloudflare's header chain, set PROXY_FIX_X_FOR to match the real number of trusted hops instead of relying on the default. statainer now sends a restrictive baseline CSP, frame protection, referrer policy, permission policy, and HSTS when the request reaches the app as HTTPS.
Login Mode
Choose the login experience with:
LOGIN_MODE: "page"
Available values:
popuppage
Dashboard Capabilities
Table and Filters
- Filter by container name, status, and Compose project.
- Sort by CPU, RAM, uptime, restarts, image, I/O, update availability, and more.
- Toggle visible columns per user.
- Export current metrics to CSV.
Charts
- Line, bar, and pie visualizations.
- Top-N comparison views for CPU, RAM, and uptime.
- Zoom and pan support where applicable.
Compose Awareness
- Group containers by Compose project.
- Inspect project summaries alongside per-container rows.
- Switch between
ContainersandCompose Stacksviews from the dashboard tabs.
Update Manager
The Update Manager is designed around safety and operator visibility.
Available Actions
Quick Updatefor a single target.Update selectedfor checked stacks or containers.Update allfor all ready targets in a tab.
Selection Workflow
- Each update-ready stack or standalone container exposes a checkbox.
- You can select a range with
Shiftto batch multiple adjacent targets. - Batch operations run sequentially to avoid overlapping recreations.
History and Rollback
- Every successful or failed managed update is recorded in history.
- Eligible successful updates expose rollback actions.
- History is persistent and survives modal reloads.
Docker Registry Authentication
To check for updates and pull images with registry credentials, start Statainer with the optional Compose override on the Docker host. It mounts an existing Docker config.json into Statainer at /root/.docker/config.json in read-only mode.
docker compose -f docker-compose.yml -f docker-compose.registry-auth.yml up -d statainer
The override uses $HOME/.docker/config.json by default. To use a different file, set DOCKER_REGISTRY_CONFIG_FILE to its absolute path on the Docker host. For other deployment methods, add the same read-only file mount to the Statainer container.
Docker can store credentials in an external helper referenced by credsStore or credHelpers. Mounting that JSON file alone only works if the helper and its credential store are also available inside the container. For a standalone mount, use a dedicated Docker config with its own auths entries backed by read-only registry tokens. Keep that file private and recreate the Statainer container after rotating its credentials.
Externally Managed Stacks
If a stack was originally created by another tool, statainer may not have the original Compose files available on disk. In that case the app can:
- mark the stack as blocked when it cannot safely manage it
- explain why the Compose files are unavailable
- use a safe external recreate workflow when runtime metadata is sufficient
This is especially relevant for stacks created through tools such as Portainer, Yacht, or similar management layers.
Notifications
Supported Providers
| Provider | Required Variables |
|---|---|
| Pushover | PUSHOVER_TOKEN, PUSHOVER_USER |
| Slack | SLACK_WEBHOOK_URL |
| Telegram | TELEGRAM_BOT_TOKEN, TELEGRAM_CHAT_ID |
| Discord | DISCORD_WEBHOOK_URL |
| ntfy | NTFY_TOPIC |
| Generic webhook | GENERIC_WEBHOOK_URL |
Common Workflow
- Set the provider environment variables.
- Restart statainer.
- Open the notification panel as an admin user.
- Enable the event types you want.
- Save the configuration.
- Use
Send testbefore relying on the provider in production.
Events That Can Trigger Alerts
- CPU threshold exceeded
- RAM threshold exceeded
- Container status changed
- Update available
Provider Examples
Pushover
PUSHOVER_TOKEN=your-application-token
PUSHOVER_USER=your-user-key
Slack
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/...
Telegram
TELEGRAM_BOT_TOKEN=123456:abcde...
TELEGRAM_CHAT_ID=123456789
Discord
DISCORD_WEBHOOK_URL=https://discord.com/api/webhooks/...
ntfy
Basic public ntfy setup:
NTFY_TOPIC=statainer-home
NTFY_SERVER_URL=https://ntfy.sh
Protected or self-hosted ntfy examples:
NTFY_TOPIC=statainer-prod
NTFY_SERVER_URL=https://ntfy.example.com
NTFY_TOKEN=tk_your_token_here
NTFY_TOPIC=statainer-prod
NTFY_SERVER_URL=https://ntfy.example.com
NTFY_USERNAME=myuser
NTFY_PASSWORD=mysecret
NTFY_TAGS=docker,monitoring,prod
NTFY_MARKDOWN=false
Generic webhook
Simple JSON webhook:
GENERIC_WEBHOOK_URL=https://example.com/hooks/statainer
Plain-text body example:
GENERIC_WEBHOOK_URL=https://example.com/hooks/statainer
GENERIC_WEBHOOK_METHOD=POST
GENERIC_WEBHOOK_CONTENT_TYPE=text/plain; charset=utf-8
GENERIC_WEBHOOK_BODY_TEMPLATE=[{event_type}] {title}\n{message}
Custom headers:
GENERIC_WEBHOOK_URL=https://example.com/hooks/statainer
GENERIC_WEBHOOK_HEADERS={"Authorization":"Bearer super-secret-token","X-Environment":"prod"}
Available placeholders:
{app}{host}{title}{message}{priority}{priority_label}{event_type}{container}{container_id}{value}{prev_value}{timestamp}{timestamp_iso}{event_json}
External API
statainer exposes an optional, token-authenticated REST API for external tools (dashboards, automation, monitoring). It is disabled by default.
- Enable it and manage keys under Settings → API access (admin only).
- Each key is created with a name, a set of scopes, and an optional expiration. Keys can be paused (reversible) or deleted to revoke access instantly.
- Tokens are shown once and stored only as a SHA-256 hash.
- Reach it at
<your dashboard URL>/api/v1, authenticating withAuthorization: Bearer <token>. This works the same whether you hit the server directly (IP:port) or through a reverse proxy.
curl -H "Authorization: Bearer $TOKEN" https://your-host/api/v1/system
Hardening is configurable via EXTERNAL_API_RATE_LIMIT_MAX,
EXTERNAL_API_AUTH_FAIL_MAX, and EXTERNAL_API_REQUIRE_HTTPS_FOR_WRITE
(see the table in API.md).
Full reference, scope list, and per-endpoint examples: API.md.
Metrics Backends
statainer can work with:
- Docker API only
- Docker API plus cAdvisor
The Docker API path is usually enough. cAdvisor is useful if you want broader metric compatibility or a more established metrics source for some host environments.
GPU Metrics
GPU metrics are available for NVIDIA-enabled hosts.
Requirements
- NVIDIA drivers on the host
nvidia-smiavailable in the runtime environment- GPU-enabled container access where applicable
Enablement
environment:
GPU_METRICS_ENABLED: true
If GPU data is available, statainer surfaces GPU load and memory usage per container in the dashboard.
Runtime Notes
CPU Usage
CPU percentage is calculated per core. On multi-core systems the effective ceiling is:
100% x number of available CPU cores
Exited Containers
Exited containers stay visible in the main table so you can:
- inspect their last known state
- review recent resource usage
- restart them directly from the UI
Safety Notice
statainer requires access to your Docker environment to inspect containers, operate on them, and evaluate updates. Use it only on systems where you understand the implications of Docker socket access and trust the deployment.
Managed updates are designed to preserve volumes, configuration, environment, networks, and other persistent state whenever possible, but you should still review updates before applying them in production.
License
This project is licensed under the MIT License. See LICENSE for details.
探索相关项目
加载中…