A real-time terminal UI tool for monitoring Docker container statistics, similar to top or htop for Linux systems.
graph TD
A[docker-stats] --> B[Docker Client]
B --> C[Docker Daemon]
C --> D[Container Stats API]
A --> E[Terminal UI]
E --> F[Real-time Display]
E --> G[Keyboard Handler]
A --> H[Data Processor]
H --> I[CPU Metrics]
H --> J[Memory Metrics]
H --> K[Network I/O]
H --> L[Block I/O]
F --> M[Color-coded Indicators]
F --> N[Sortable Tables]
F --> O[Auto-refresh]
G --> P[Sort Controls]
G --> Q[Refresh Command]
G --> R[Navigation]
flowchart LR
subgraph User
A[Start docker-stats]
end
subgraph Application
B[Initialize Client]
C{Docker Available?}
D[Start TUI]
E[Fetch Stats]
F[Render Display]
G[Wait Interval]
H[Handle Input]
end
subgraph Docker
I[Docker Daemon]
J[Container List]
K[Container Stats]
end
A --> B
B --> C
C -->|No| X[Exit with Error]
C -->|Yes| D
D --> E
E --> I
I --> J
J --> K
K --> F
F --> G
G --> E
H -->|q/Ctrl+C| Y[Exit]
H -->|r| E
H -->|c/m/n| F
H -->|β/β| F
- π Real-time statistics - CPU, Memory, Network I/O, Block I/O
- π¨ Color-coded indicators - Visual resource usage warnings
- β¨οΈ Keyboard navigation - Sort, refresh, and navigate with hotkeys
- π Auto-refresh - Configurable refresh interval
- π¦ Lightweight - Single binary, no dependencies
Download the appropriate binary for your platform and architecture from the latest release:
# AMD64 (Intel/AMD)
wget https://github.com/spagu/docker-stats/releases/latest/download/docker-stats-$(curl -s https://api.github.com/repos/spagu/docker-stats/releases/latest | grep '"tag_name"' | cut -d'"' -f4)-linux-amd64.tar.gz
tar -xzf docker-stats-*-linux-amd64.tar.gz
sudo mv docker-stats /usr/local/bin/
# ARM64 (ARM)
wget https://github.com/spagu/docker-stats/releases/latest/download/docker-stats-$(curl -s https://api.github.com/repos/spagu/docker-stats/releases/latest | grep '"tag_name"' | cut -d'"' -f4)-linux-arm64.tar.gz
tar -xzf docker-stats-*-linux-arm64.tar.gz
sudo mv docker-stats /usr/local/bin/# Intel
wget https://github.com/spagu/docker-stats/releases/latest/download/docker-stats-$(curl -s https://api.github.com/repos/spagu/docker-stats/releases/latest | grep '"tag_name"' | cut -d'"' -f4)-darwin-amd64.tar.gz
tar -xzf docker-stats-*-darwin-amd64.tar.gz
sudo mv docker-stats /usr/local/bin/
# Apple Silicon (M1/M2)
wget https://github.com/spagu/docker-stats/releases/latest/download/docker-stats-$(curl -s https://api.github.com/repos/spagu/docker-stats/releases/latest | grep '"tag_name"' | cut -d'"' -f4)-darwin-arm64.tar.gz
tar -xzf docker-stats-*-darwin-arm64.tar.gz
sudo mv docker-stats /usr/local/bin/# Download and extract (PowerShell)
$version = (Invoke-RestMethod -Uri "https://api.github.com/repos/spagu/docker-stats/releases/latest" | Select-Object -ExpandProperty tag_name)
Invoke-WebRequest -Uri "https://github.com/spagu/docker-stats/releases/latest/download/docker-stats-$version-windows-amd64.zip" -OutFile "docker-stats.zip"
Expand-Archive -Path "docker-stats.zip" -DestinationPath "."
Move-Item "docker-stats.exe" -Destination "$env:USERPROFILE\Local\Programs\docker-stats\"# AMD64 only
wget https://github.com/spagu/docker-stats/releases/latest/download/docker-stats-$(curl -s https://api.github.com/repos/spagu/docker-stats/releases/latest | grep '"tag_name"' | cut -d'"' -f4)-freebsd-amd64.tar.gz
tar -xzf docker-stats-*-freebsd-amd64.tar.gz
sudo mv docker-stats /usr/local/bin/# Clone the repository
git clone https://github.com/spagu/docker-stats.git
cd docker-stats
# Build
make build
# Or install to /usr/local/bin
make installgo build -o docker-stats .# Run with default settings (2s refresh)
./docker-stats
# Custom refresh interval
./docker-stats -interval 5s
# Show all containers (including stopped)
./docker-stats -all
# Show help
./docker-stats -help
# Show version
./docker-stats -version| Key | Action |
|---|---|
q / Ctrl+C |
Quit |
r |
Force refresh |
c |
Sort by CPU usage |
m |
Sort by Memory usage |
n |
Sort by container Name |
β / β |
Navigate containers |
| Column | Description |
|---|---|
| NAME | Container name |
| STATUS | Container state (running, stopped, etc.) |
| CPU% | CPU usage percentage |
| MEM USAGE | Memory usage (used / limit) |
| MEM% | Memory usage percentage |
| NET I/O | Network input/output bytes |
| BLOCK I/O | Disk read/write bytes |
| PIDS | Number of processes |
| IMAGE SIZE | Size of the container image |
- β¬ White: < 20%
- π© Green: 20-50%
- π¨ Yellow: 50-80%
- π₯ Red: > 80%
- β¬ White: < 40%
- π© Green: 40-70%
- π¨ Yellow: 70-90%
- π₯ Red: > 90%
- Go 1.25 or later
- Docker daemon running
- User must have permissions to access Docker socket
# Install dependencies
make deps
# Format code
make fmt
# Run linter
make lint
# Run tests
make test
# Run tests with coverage
make test-coverage
# Security scan
make security
# Build binary
make build
# Build for all platforms
make build-all
# Run all checks
make allmake dev-toolsThis installs:
golangci-lint- Lintergosec- Security scannergovulncheck- Vulnerability checkergoimports- Import formatter
stats/
βββ main.go # Entry point
βββ go.mod # Go module definition
βββ go.sum # Dependency checksums
βββ Makefile # Build automation
βββ README.md # This file
βββ .gitignore # Git ignore rules
βββ internal/
βββ docker/
β βββ client.go # Docker client wrapper
β βββ client_test.go # Client tests
β βββ format.go # Formatting utilities
βββ ui/
βββ app.go # Terminal UI application
βββ app_test.go # UI tests
- Docker daemon must be running
- User must have permissions to access Docker socket (typically member of
dockergroup or root)
# Add user to docker group (requires logout/login)
sudo usermod -aG docker $USEREnsure Docker is running:
sudo systemctl start dockerAdd your user to the docker group:
sudo usermod -aG docker $USER
# Then logout and login againCheck if containers are running:
docker psUse -all flag to show stopped containers:
./docker-stats -allBSD 3-Clause License - see LICENSE for details.
- docker stats - Official Docker stats command
- ctop - Top-like interface for container metrics
- lazydocker - Terminal UI for Docker
