A comprehensive Docker container monitoring dashboard that provides real-time container statistics through multiple interfaces, including HTTP API, CLI, GRPC, and Prometheus metrics.
- Real-time Container Monitoring: Track CPU usage, memory usage, network I/O, and disk I/O
- Multiple Interface Options:
- HTTP Server: REST API with WebSocket support for real-time updates
- CLI Interface: Interactive terminal-based dashboard using Bubble Tea
- Prometheus Integration: Export metrics for Prometheus monitoring
- Protocol Buffers: gRPC support for efficient data serialization
- Caching: Redis integration for improved performance
- Cross-platform: Built with Go, supports multiple operating systems
- gRPC API: Protocol buffer-based service for efficient communication
- Docker Integration: Direct Docker API integration for container management
- Development Tools: Mock mode for testing and development
- Go 1.24 or later
- Docker (for container monitoring)
- Redis (for caching, optional for basic functionality)
- Prometheus (optional, for metrics collection)
# Clone the repository
git clone https://github.com/raghavendrarq/container-dsh
cd container-dsh
# Build the application
go build -o bin/container-dsh ./cmd/container-dsh
# Or use the Makefile
make help# Build the Docker image
docker build -t container-dsh .
# Run the container
docker run -p 8080:8080 -p 3000:3000 container-dsh# Run the server mode (default)
./bin/container-dsh --mode=server
# Or run directly with Go
go run ./cmd/container-dsh --mode=serverThe server will start on port 8080 by default.
# Run the interactive CLI
./bin/container-dsh --mode=cli# Start Prometheus mode
./bin/container-dsh --mode=prometheusMetrics will be available at http://localhost:8080/metrics
Container-DSH supports multiple operation modes:
Starts an HTTP server with REST API and WebSocket support.
./container-dsh --mode=serverEndpoints:
GET /- List all containersGET /metrics- Get metrics for all containersGET /metrics/{id}- Get metrics for a specific containerWS /ws/- WebSocket endpoint for real-time updatesWS /ws/container- Container-specific WebSocket updates
Interactive terminal interface for monitoring containers.
./container-dsh --mode=cliFeatures:
- Navigate with arrow keys or j/k
- Select/deselect options with Enter or Space
- Quit with q or Ctrl+C
Export container metrics in Prometheus format.
./container-dsh --mode=prometheusMetrics Exported:
container_dsh_cpu_usage- CPU usage percentagecontainer_dsh_mem_usage- Memory usage in bytescontainer_dsh_net_io- Network I/O statisticscontainer_dsh_disk_io- Disk I/O statistics
For testing and development purposes.
./container-dsh --mode=mockgRPC server mode.
./container-dsh --mode=pbWork in Progress
./container-dsh --mode=loggerNote: The current Makefile has some build configuration issues. Manual building is recommended.
# Show all available targets
make help
# Generate protocol buffers
make proto
# Clean build artifacts
make clean# Run in server mode
./start.sh server
# Run in CLI mode
./start.sh cli
# Run with Prometheus (starts both Prometheus and the app)
./start.sh prometheusContainer-DSH uses the following environment variables:
PORT: Server port (default::8080)CLIENT_URL: Frontend client URL for CORS (required for server mode)
export PORT=":8080"
export CLIENT_URL="http://localhost:3000"Redis is used for caching container information to improve performance. The application will attempt to connect to Redis on the default port (6379), but will fall back to direct Docker API calls if Redis is unavailable.
Note: If Redis is not available, you may see warning messages, but the application will continue to function.
If using Prometheus integration, configure prometheus.yml:
global:
scrape_interval: 1s
evaluation_interval: 3s
scrape_configs:
- job_name: "container-dsh"
static_configs:
- targets: ["localhost:8080"]Returns a list of all containers.
Response:
[
"container_id_1",
"container_id_2"
]Returns metrics for all containers.
Response:
[
"container_id_1",
"container_id_2"
]Returns detailed metrics for a specific container.
Response:
{
"id": "container_id",
"name": "container_name",
"status": 2,
"cpu_usage": 25.5,
"mem_usage": 1073741824,
"net_io": 1024,
"disk_io": 2048
}General WebSocket endpoint for real-time updates.
Container-specific WebSocket endpoint.
Container-DSH also provides a gRPC service defined in api/proto/v1/container.proto.
Service Definition:
service ContainerService {
rpc GetContainerStats(ContainerStatRequest) returns (Container);
}Run gRPC Server:
./bin/container-dsh --mode=pb1: Created2: Running3: Paused4: Restarting5: Removing6: Exited7: Dead
- Go 1.24+
- Docker (running and accessible)
- Protocol Buffers Compiler (
protoc) - for gRPC development - Redis (optional, for caching features)
container-dsh/
├── api/ # API definitions
│ ├── gen/go/ # Generated Go code
│ └── proto/v1/ # Protocol buffer definitions
├── cmd/ # Application entry points
│ ├── cli/ # CLI mode
│ ├── container-dsh/ # Main application
│ ├── mock/ # Mock mode
│ ├── pb/ # Protocol buffer mode
│ ├── prom/ # Prometheus mode
│ └── server/ # Server mode
├── internal/ # Internal packages
│ ├── cache/ # Redis caching
│ ├── cli/ # CLI models and logic
│ ├── config/ # Configuration management
│ └── container/ # Container operations
├── pkg/ # Public packages
│ ├── aggr/ # Aggregator
│ ├── collector/ # Data collection
│ ├── http/ # HTTP server
│ ├── logger/ # Logging utilities
│ ├── pb/ # Protocol buffer services
│ ├── prom/ # Prometheus integration
│ └── snapshot/ # Snapshot utilities
├── Dockerfile # Docker configuration
├── Makefile # Build configuration
├── go.mod # Go module definition
└── README.md # This file
- Container Metrics: Add new metrics in
internal/container/model.go - HTTP Endpoints: Add routes in
pkg/http/server.goand handlers inpkg/http/handler.go - CLI Options: Extend the CLI model in
internal/cli/model.go - Prometheus Metrics: Add metrics in
pkg/prom/model.go
# Install dependencies
go mod download
# Build the application manually (recommended)
go build -o bin/container-dsh ./cmd/container-dsh
# Test the build
./bin/container-dsh --help
# Generate protocol buffers (requires protoc)
make proto
# Build Docker image
docker build -t container-dsh ."redis connection failed":
- Redis is not running or not accessible
- Solution: Install and start Redis, or ignore the warning (app will work without caching)
"error in getting containers":
- Docker is not running or not accessible
- Solution: Start Docker daemon and ensure proper permissions
Build errors with Makefile:
- Current Makefile has configuration issues
- Solution: Use manual build command:
go build -o bin/container-dsh ./cmd/container-dsh
Permission denied accessing Docker:
- User doesn't have Docker permissions
- Solution: Add user to docker group or run with sudo
- Bubble Tea - For the beautiful CLI interface
- Docker - For containerization support
- Prometheus - For metrics collection
- Go - For the robust foundation
If you encounter any problems or have questions, please:
- Check the Issues page
- Create a new issue if your problem isn't already reported
- Provide as much detail as possible including:
- Operating system
- Go version
- Docker version
- Steps to reproduce the issue
Made with ❤️ by RaghavendraRQ