A comprehensive full-stack Docker monitoring application with real-time WebSocket updates, featuring a modern Next.js web dashboard and Node.js backend. Monitor any Docker network with container stats, system metrics, and live logs.
- Live Container Stats: CPU, Memory, and Network usage updated every second via WebSocket
- System Stats: Host machine metrics (CPU, Memory, Disk) streamed in real-time
- Container List: Auto-updating container list every 5 seconds
- Zero Polling: All data pushed via WebSocket - no REST API polling
- Status Indicators: Visual indicators (green for running, red for stopped, yellow for restarting)
- Container Controls: Start, Stop, Restart, and Delete containers with confirmation dialogs
- Live Logs: Stream container logs with auto-refresh
- Docker Compose Integration: Control compose stacks (up, down, rebuild)
- JWT Authentication: Secure token-based authentication
- Role-Based Access: Admin and viewer roles
- Protected Routes: All API endpoints secured with JWT middleware
- WebSocket Authentication: Socket.IO connections authenticated via JWT
- Cyberpunk Theme: Futuristic neon-styled interface
- Responsive Design: Works on desktop, tablet, and mobile
- Real-Time Updates: Live data without page refresh
- Modal Dialogs: View logs and confirm actions without navigation
The main interface showing all Docker containers with their status indicators.
Click on "View Logs" to see the last 10 lines of logs for any container.
- Docker Desktop (Windows/Mac/Linux)
- Docker Compose
- Ports available: 80, 4000, 8081, 8082, 19000-19002
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Browser Client β
β - Next.js Web Dashboard (Port 3002) β
β - React Components with TanStack Query β
β - Socket.IO Client for Real-Time Updates β
ββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββ
β
β HTTP/HTTPS + WebSocket
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Nginx (Port 8080) β
β - Reverse Proxy & Load Balancer β
β - Routes /api/* β Backend API β
β - Routes /socket.io/* β WebSocket Server β
β - WebSocket Upgrade Support β
ββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββ
β
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Backend Server (Port 4000) β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Express.js REST API β β
β β - Container CRUD operations β β
β β - System stats endpoints β β
β β - Authentication (JWT) β β
β β - Docker Compose control β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β Socket.IO WebSocket Server β β
β β - Real-time container stats (1s interval) β β
β β - Real-time system stats # Express + Socket.IO server
β βββ Dockerfile # Backend container config
β βββ package.json # Dependencies: express, socket.io, dockerode, jwt
β
βββ web/
β βββ app/
β β βββ layout.tsx # Next.js root layout
β β βββ page.tsx # Login/Dashboard entry point
β β βββ globals.css # Global styles
β βββ components/
β β βββ Dashboard.tsx # Main dashboard container
β β βββ ContainerCard.tsx # Individual container display
β β βββ SystemStats.tsx # System metrics display
β β βββ LogModal.tsx # Container logs viewer
β β βββ LoginScreen.tsx # Authentication UI
β β βββ ConfirmModal.tsx # Action confirmation dialog
β βββ hooks/
β β βββ useContainers.ts # WebSocket hook for containers
β β βββ useContainerStats.ts # WebSocket hook for container stats
β β βββ useSystemStats.ts # WebSocket hook for system stats
β βββ contexts/
β β βββ AuthContext.tsx # Authentication state management
β βββ lib/
β β βββ api.ts # API client functions
β βββ Dockerfile # Web dashboard container config
β βββ next.config.ts # Next.js configuration
β βββ tailwind.config.ts # Tailwind CSS configuration
β βββ package.json # Dependencies: next, react, socket.io-client
β
βββ nginx/
β βββ nginx.conf # Nginx reverse proxy + WebSocket config
β βββ Dockerfile # Nginx container config
β
βββ mock-projects/ # Sample projects to monitor
β βββ express-api/ # Node.js Express API
β βββ dotnet-api/ # .NET Core API
β βββ nextjs-app/ # Next.js application
β βββ mongodb-init/ # MongoDB initialization
β βββ postgresql-init/ # PostgreSQL initialization
β
βββ docker-compose.yml # Orchestrates all services
βββ .env # Environment variables
βββ README.md # This file
βββ PROJECT-SETUP.md # Detailed setup guide
βββ WEBSOCKET-IMPLEMENTATION.md # WebSocket architecture docs Docker Engine (Unix Socket) β
β /var/run/docker.sock β
β - Container lifecycle management β
β - Stats streaming β
β - Log access β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Docker Networks β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
β β bjit-network (Bridge Network) β β
β β βββ express-api (Node.js API) β β
β β βββ dotnet-api (.NET Core API) β β
β β βββ nextjs-app (Next.js Web App) β β
β β βββ mongodb (Database) β β
β β βββ postgresql (Database) β β
β β βββ dnmonitor-backend (Monitoring Backend) β β
β β βββ dnmonitor-web (Monitoring Dashboard) β β
β β βββ dnmonitor-nginx (Reverse Proxy) β β
β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Browser β Nginx β Web Dashboard (Next.js)
Browser β Static HTML/JS/CSS
Browser β POST /api/auth/login β Backend
Backend β Verify credentials β Generate JWT
Backend β Return JWT token
Browser β Store token in localStorage
Browser β Socket.IO Client β Connect with JWT token
Nginx β Upgrade HTTP to WebSocket
Backend β Verify JWT β Accept connection
Backend β Emit initial data
Backend β Query Docker API every 1s
Backend β Calculate stats (CPU, Memory, Network)
Backend β Emit via Socket.IO β Browser
Browser β Update UI components
Browser β POST /api/containers/:id/start β Backend
Backend β Verify JWT β Call Docker API
Docker β Start container
Backend β Return success
Browser β WebSocket receives updated container list
- Client connects and subscribes to a specific container
- Backend immediately sends current stats
- Backend sets up interval (1 second) to fetch stats from Docker
- Stats are emitted to client via WebSocket every second
- Client unsubscribes when component unmounts
- Client subscribes to system stats on dashboard load
- Backend reads
/proc/stat,/proc/meminfo, disk stats - Stats calculated: CPU usage, memory usage, disk usage
- Emitted every second to all subscribed clients
- Updates in real-time without polling
- Client subscribes to container list
- Backend queries Docker API for all containers
- Filters by configured network (bjit-network)
- Emits complete list every 5 seconds
- UI updates automatically when containers change state
βββββββββββββββ
β Login β
β Screen β
ββββββββ¬βββββββ
β
β POST /api/auth/login
β {username, password}
β
ββββββββββββββββββββ
β JWT Verify β
β bcrypt compare β
ββββββββ¬ββββββββββββ
β
β JWT Token
β
ββββββββββββββββββββ
β localStorage β
β Save token β
ββββββββ¬ββββββββββββ
β
βββ REST API calls (Authorization: Bearer <token>)
β
βββ WebSocket connect (auth: {token})
The backend uses Dockerode library to communicate with Docker:
// Connect to Docker socket
const docker = new Docker({
socketPath: '/var/run/docker.sock'
});
// List containers in specific network
const containers = await docker.listContainers({ all: true });
const filtered = containers.filter(c =>
MONITORED_CONTAINERS.some(name => c.Names[0].includes(name))
);
// Get real-time stats
const container = docker.getContainer(containerId);
const stats = await container.stats({ stream: false });
// Calculate CPU percentage
const cpuDelta = stats.cpu_stats.cpu_usage.total_usage -
stats.precpu_stats.cpu_usage.total_usage;
const systemDelta = stats.cpu_stats.system_cpu_usage -
stats.precpu_stats.system_cpu_usage;
const cpuPercent = (cpuDelta / systemDelta) *
Prerequisites
- **Docker Desktop** (Windows/Mac/Linux) - [Download](https://www.docker.com/products/docker-desktop/)
- **Docker Compose** v2.0+ (included with Docker Desktop)
- **Git** (to clone the repository)
- **Available Ports**: 3002, 4000, 8080, and ports 3000-5432 for mock services
### 1. Clone the Repository
```bash
git clone <repository-url>
cd DNMonitorCreate a .env file in the root directory:
# JWT Configuration
JWT_SECRET=your-super-secret-jwt-key-change-in-production
JWT_EXPIRES_IN=24h
# Environment
NODE_ENV=production
# MongoDB Configuration
MONGO_INITDB_DATABASE=testdb
# PostgreSQL Configuration
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
POSTGRES_DB=testdbοΏ½ Detailed Setup Guide for Custom Docker Networks
DNMonitor can monitor any Docker network. Follow these steps to adapt it for your infrastructure:
# List all Docker networks
docker network ls
# Inspect your target network
docker network inspect your-network-name
# List containers in the network
docker network inspect your-network-name | grep -A 3 "Containers"Edit backend/src/index.js:
// Replace this array with your container names
const MONITORED_CONTAINERS = [
'your-container-1',
'your-container-2',
'your-database',
'your-api-service',
// ... add all containers you want to monitor
];Modify the docker-compose.yml to use your network:
services:
backend:
networks:
- your-network-name # Change this
depends_on:
- your-container-1 # Update dependencies
- your-container-2
web:
networks:
- your-network-name # Change this
nginx:
networks:
- your-network-name # Change this
networks:
your-network-name:
external: true # If network already exists
# OR
driver: bridge # If creating new network
name: your-network-nameReference
All endpoints require JWT authentication (except login).
POST /api/auth/login
{
"username": "admin",
"password": "admin123"
}Response:
{
"success": true,
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"user": {
"id": 1,
"username": "admin",
"email": "admin@dnmonitor.com",
"role": "admin"
}
}GET /api/auth/verify
- Headers:
Authorization: Bearer <token> - Returns: Current user info
POST /api/auth/logout
- Client-side logout (JWT is stateless)
& Dependencies
- Next.js 16.1.2 - React framework with server-side rendering
- React 19.2.3 - UI component library
- TypeScript 5.x - Type-safe JavaScript
- TanStack Query 5.62.12 - Server state management
- Socket.IO Client 4.6.1 - WebSocket client
- Axios 1.13.2 - HTTP client
- Tailwind CSS 4.x - Utility-first CSS framework
- Lucide React 0.562.0 - Icon library
- Framer Motion 12.26.2 - Animation library
- Node.js 20-alpine - JavaScript runtime
- Express 4.18.2 - Web framework
- Socket.IO 4.8.3 - WebSocket server
- Dockerode 4.0.0 - Docker API client
- JWT (jsonwebtoken) 9.0.2 - Authentication tokens
- bcryptjs 2.4.3 - Password hashing
- CORS 2.8.5 - Cross-origin resource sharing
- Docker & Docker Compose - Containerization
- Nginx 1.29.1-alpine - Reverse proxy & load balancer
- ESM (ES Modules) - Modern JavaScript modules
- Hot Module Replacement - Development experience
Create .env file in project root:
# JWT Configuration
JWT_SECRET=your-super-secret-jwt-key-change-in-production
JWT_EXPIRES_IN=24h
# Node Environment
NODELocal Development Setup
```bash
# Clone repository
git clone <repository-url>
cd DNMonitor
# Start all services
docker compose up -d --build
# Watch logs
docker compose logs -f dnmonitor-backend dnmonitor-web
# Access dashboard
open http://localhost:3002The web dashboard supports hot module replacement:
# Edit any file in web/
# Changes automatically reflect in browser
# No rebuild needed for most changes
# If adding new dependencies:
cd web
npm install new-package
cd ..
docker compose build web
docker compose up -d web# Edit backend/src/index.js
# Restart backend
docker compose restart dnmonitor-backend
# Or rebuild if dependencies changed
docker compose build dnmonitor-backend
docker compose up -d dnmonitor-backendmmon Issues
Symptoms: Dashboard shows "Failed to load stats"
Solutions:
# Check backend is running
docker ps | grep dnmonitor-backend
# Check backend logs for Socket.IO
docker logs dnmonitor-backend | grep "Socket.IO"
# Verify nginx WebSocket proxy
docker exec dnmonitor-nginx nginx -t
# Restart services
docker compose restart dnmonitor-backend dnmonitor-nginxSymptoms: "Invalid or expired token"
Solutions:
# Clear browser localStorage
# In browser console:
localStorage.clear()
# Regenerate JWT secret
# Edit .env and change JWT_SECRET
docker compose up -d --buildSymptoms: Stats frozen or not displaying
Solutions:
# Check Docker socket permissions
docker exec dnmonitor-backend ls -la /var/run/docker.sock
# Should show: srw-rw----
# If not, restart Docker Desktop
# Verify Docker API connection
dockerAdditional Notes
### Security Considerations
- **JWT Secret**: Change `JWT_SECRET` in production
- **CORS**: Restrict origins in production
- **Docker Socket**: Mounting Docker socket gives full access - use with caution
- **HTTPS**: Use SSL/TLS certificates in production
- **Password Hashing**: All passwords stored as bcrypt hashes
- **Token Expiration**: JWT tokens expire after 24 hours (configurable)
### Performance Optimization
- **WebSocket Intervals**: Adjust update frequencies based on your needs
- Container stats: 1 second (real-time)
- System stats: 1 second (real-time)
- Container list: 5 seconds (moderate)
- **Resource Limits**: Set memory/CPU limits in docker-compose.yml
- **Nginx Caching**: Enable for static assets
- **Connection Pooling**: Socket.IO handles connection reuse
### Scalability
The system is designed for monitoring 10-50 containers on a single host. For larger deployments:
Contributions are welcome! Here's how you can help:
### Reporting Bugs
1. Check existing issues
2. Create new issue with:
- Description of the bug
- Steps to reproduce
- Expected vs actual behavior
- Environment details (OS, Docker version)
- Logs and error messages
### Suggesting Features
1. Search existing feature requests
2. Create new issue with:
- Clear description of feature
- Use cases and benefits
- Mockups or examples (if applicable)
### Pull Requests
1. Fork the repository
2. Create feature branch (`git checkout -b feature/amazing-feature`)
3. Commit changes (`git commit -m 'Add amazing feature'`)
4. Push to branch (`git push origin feature/amazing-feature`)
5. Open Pull Request
### Development Guidelines
- Follow existing code style
- Add comments for complex logic
- Test changes locally
- Update documentation if needed
- Keep commits focused and atomic
## π License
This project is open source and available under the MIT License.
## π Acknowledgments
- **Docker** - Container platform
- **Socket.IO** - Real-time WebSocket library
- **Next.js** - React framework
- **Express** - Node.js web framework
- **Dockerode** - Docker API client
- **TanStack Query** - Server state management
- **Tailwind CSS** - Utility-first CSS framework
## π§ Support
For questions and support:
- π Read the documentation
- π Report bugs via GitHub Issues
- π‘ Request features via GitHub Issues
- π Check `WEBSOCKET-IMPLEMENTATION.md` for WebSocket details
- π See `PROJECT-SETUP.md` for setup instructions
## π Show Your Support
If you find this project helpful, please consider:
- β Starring the repository
- π Sharing with others
- π Reporting bugs
- π‘ Suggesting features
- π€ Contributing code
---
**Built with β€οΈ using Docker, Next.js, Socket.IO, and Node.js**
**Real-Time Monitoring Made Simple** π
Currently, no data is persisted (stateless design). To add persistence:
1. **Metrics Storage**: Add InfluxDB or Prometheus
2. **User Management**: Add PostgreSQL/MySQL for user database
3. **Historical Data**: Store stats in time-series database
4. **Alerts**: Add notification system with alert history
### Browser Compatibility
Tested and working on:
- β
Chrome 120+
- β
Firefox 121+
- β
Safari 17+
- β
Edge 120+
WebSocket support required (all modern browsers).
### Known Limitations
- Monitors only one Docker network at a time
- No historical data/metrics (real-time only)
- No alerts/notifications system
- Limited to single Docker host (no multi-host support)
- Stats calculation works on Linux containers (some limitations on Windows containers)
### Future Roadmap
- [ ] Multi-host Docker monitoring
- [ ] Historical metrics with charts
- [ ] Alert system (email, Slack, webhooks)
- [ ] User management UI
- [ ] Role-based permissions
- [ ] Container deployment from UI
- [ ] Dockerfile execution
- [ ] Image management
- [ ] Network management
- [ ] Volume management
- [ ] Docker Swarm support
- [ ] Kubernetes integration
- [ ] Mobile responsive improvements
- [ ] Dark/Light theme toggle
- [ ] Export logs/metrics
- [ ] Scheduled container actions
- [ ] Resource usage predictions
- [ ] Cost analysis dashboard
**Symptoms**: "No containers found" in dashboard
**Solutions**:
```bash
# Check MONITORED_CONTAINERS in backend/src/index.js
docker exec dnmonitor-backend cat src/index.js | grep MONITORED_CONTAINERS
# Verify containers are running
docker ps --filter network=bjit-network
# Check container names match
docker ps --format "{{.Names}}"Symptoms: "failed to solve: process exited with code 1"
Solutions:
# Clear Docker cache
docker builder prune -a
# Build with no cache
docker compose build --no-cache
# Check for syntax errors in files
docker compose configSymptoms: nginx container status shows "Restarting"
Solutions:
# Check nginx config syntax
docker exec dnmonitor-nginx nginx -t
# View nginx error logs
docker logs dnmonitor-nginx
# Common fix: ensure port 8080 is available
netstat -ano | findstr :8080Symptoms: "Type error" during web build
Solutions:
# Check web/tsconfig.json
cat web/tsconfig.json
# Reinstall dependencies
cd web
rm -rf node_modules package-lock.json
npm install
cd ..
docker compose build web# Check all container status
docker compose ps
# View all logs
docker compose logs
# Check container health
docker inspect dnmonitor-backend --format='{{.State.Health.Status}}'
# Network connectivity test
docker exec dnmonitor-web ping backend
# WebSocket connection test
docker logs dnmonitor-backend --tail 50 | grep "Client connected"
# API connectivity test
docker exec dnmonitor-web curl http://backend:4000/health# Check which container is consuming CPU
docker stats --no-stream
# Reduce WebSocket update frequency
# Edit backend/src/index.js
# Change interval from 1000ms to 2000ms or higher# Monitor memory usage
docker stats --format "table {{.Name}}\t{{.MemUsage}}"
# Restart problematic container
docker compose restart <service-name>
# Set memory limits in docker-compose.yml
services:
backend:
mem_limit: 512mIf you're still having issues:
- Check logs:
docker compose logs -f - Verify environment:
docker compose config - Test connectivity:
curl http://localhost:8080/health - Review documentation: See
WEBSOCKET-IMPLEMENTATION.md - Create issue: Include logs and error messages
# Test authentication
curl -X POST http://localhost:8080/api/auth/login \
-H "Content-Type: application/json" \
-d '{"username":"admin","password":"admin123"}'
# Test container list (with token)
curl http://localhost:8080/api/containers \
-H "Authorization: Bearer <your-token>"
# Test health endpoint
curl http://localhost:8080/healthUse browser console:
// Connect to WebSocket
const socket = io('http://localhost:8080', {
auth: { token: 'your-jwt-token' }
});
// Subscribe to events
socket.on('connect', () => console.log('Connected'));
socket.emit('subscribe:containers');
socket.on('containers:list', data => console.log(data));# Monitor Docker stats
docker stats
# Check container resource usage
docker exec dnmonitor-backend top
# View network connections
docker exec dnmonitor-backend netstat -an | grep 4000# Stop all services
docker compose down
# Remove volumes (resets data)
docker compose down -v
# Remove images
docker compose down --rmi all
# Complete cleanup
docker compose down -v --rmi all --remove-orphans
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_read_timeout 86400;
}- Returns: Host machine metrics (CPU, Memory, Disk, Uptime)
GET /health
- Returns: Service health check
Connect
io.connect('http://localhost:8080', {
auth: { token: 'your-jwt-token' }
})Subscribe to Container Stats
socket.emit('subscribe:container:stats', {
containerName: 'express-api'
})Unsubscribe from Container Stats
socket.emit('unsubscribe:container:stats', {
containerName: 'express-api'
})Subscribe to System Stats
socket.emit('subscribe:system:stats')Unsubscribe from System Stats
socket.emit('unsubscribe:system:stats')Subscribe to Containers List
socket.emit('subscribe:containers')Unsubscribe from Containers List
socket.emit('unsubscribe:containers')Container Stats
socket.on('container:stats', (data) => {
console.log(data);
// {
// container: 'express-api',
// cpu: '5.23%',
// memory: {
// usage: '45.23 MB',
// limit: '512.00 MB',
// percent: '8.83%',
// used: '45.23 MB',
// total: '512.00 MB'
// },
// network: {
// rx: '1.23 MB',
// tx: '0.87 MB'
// }
// }
})System Stats
socket.on('system:stats', (data) => {
console.log(data);
// {
// hostname: 'docker-host',
// platform: 'Linux',
// arch: 'x86_64',
// cpu: {
// model: 'Intel Core i7',
// percent: '15.42%',
// cores: 8
// },
// memory: {
// total: '15.42 GB',
// used: '8.23 GB',
// available: '7.19 GB',
// percent: '53.37%'
// },
// disk: {
// total: '500G',
// used: '250G',
// percent: '50%'
// },
// uptime: 12345,
// timestamp: '2026-02-05T12:00:00.000Z'
// }
})Containers List
socket.on('containers:list', (data) => {
console.log(data);
// [
// {
// id: 'abc123...',
// name: 'express-api',
// image: 'node:20-alpine',
// state: 'running',
// status: 'Up 2 hours',
// created: 1707132000,
// ports: [
// { private: 3000, public: 3000, type: 'tcp' }
// ]
// }
// ]
})Error Events
socket.on('container:stats:error', (data) => {
console.error(data.error);
})
socket.on('system:stats:error', (data) => {
console.error(data.error);
})
socket.on('containers:error', (data) => {
console.error(data.error);
})
- "3002:3000" # Change 3002 to your preferred portCreate environment-specific files:
# Development
.env.development
# Production
.env.production
# Staging
.env.stagingLoad with:
docker compose --env-file .env.production up -dFor production with HTTPS, update nginx/nginx.conf:
server {
listen 443 ssl http2;
server_name your-domain.com;
ssl_certificate /etc/nginx/ssl/cert.pem;
ssl_certificate_key /etc/nginx/ssl/key.pem;
# WebSocket upgrade
location /socket.io/ {
proxy_pass http://backend:4000/socket.io/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}Mount SSL certificates in docker-compose.yml:
nginx:
volumes:
- ./ssl:/etc/nginx/ssl:roAdd users in backend/src/index.js:
const USERS = [
{
id: 1,
username: 'admin',
email: 'admin@yourcompany.com',
passwordHash: '$2a$10$...', // Generate with bcrypt
role: 'admin'
},
{
id: 2,
username: 'developer',
email: 'dev@yourcompany.com',
passwordHash: '$2a$10$...',
role: 'viewer'
}
];Generate password hashes:
const bcrypt = require('bcryptjs');
const hash = await bcrypt.hash('your-password', 10);
console.log(hash);# 1. Copy project to server
scp -r DNMonitor user@your-server:/opt/
# 2. SSH into server
ssh user@your-server
# 3. Navigate to project
cd /opt/DNMonitor
# 4. Set environment variables
nano .env
# 5. Build and start
docker compose up -d --build
# 6. Check status
docker compose ps# Initialize swarm
docker swarm init
# Deploy stack
docker stack deploy -c docker-compose.yml dnmonitor
# Check services
docker stack services dnmonitor
# View logs
docker service logs -f dnmonitor_backendConvert docker-compose.yml to Kubernetes manifests:
# Install kompose
curl -L https://github.com/kubernetes/kompose/releases/download/v1.31.2/kompose-linux-amd64 -o kompose
chmod +x kompose
sudo mv kompose /usr/local/bin/kompose
# Convert
kompose convert -f docker-compose.yml
# Deploy
kubectl apply -f .For monitoring multiple Docker daemons:
# On each host
git clone <repo>
cd DNMonitor
docker compose up -d
# Access each at:
# http://host1:3002
# http://host2:3002Expose Docker socket via TCP (secure with TLS):
# On remote host
dockerd -H tcp://0.0.0.0:2376 --tlsverify --tlscacert=ca.pem --tlscert=server-cert.pem --tlskey=server-key.pemUpdate backend/src/index.js:
const docker = new Docker({
host: 'remote-host-ip',
port: 2376,
ca: fs.readFileSync('ca.pem'),
cert: fs.readFileSync('cert.pem'),
key: fs.readFileSync('key.pem')
});- Web Application: http://localhost:8081
- API Endpoint: http://localhost/api/containers
- Health Check: http://localhost/health
# View all logs
docker compose logs -f
# View specific service logs
docker compose logs -f frontend
docker compose logs -f backend
docker compose logs -f nginx# Copy backend and nginx folders to your server
scp -r backend nginx docker-compose.yml user@your-server:/path/to/dnmonitor/cd /path/to/dnmonitor
docker compose up --build -dcurl http://localhost/api/containers# Allow port 80
sudo ufw allow 80/tcp- Android: Google Play Store
- iOS: App Store
const API_URL = 'http://YOUR_SERVER_IP/api';Replace YOUR_SERVER_IP with your actual server IP address.
cd frontend
npm installnpx expo startNotes:
- Make sure your server IP is accessible from your mobile device
- If using HTTPS, update the API_URL to use
https:// - For production, consider using environment variables or a config file for the API URL
GET /api/containers
Response:
[
{
"id": "abc123...",
"name": "dnmonitor-backend",
"image": "dnmonitor-backend:latest",
"state": "running",
"ports": [
{
"private": 4000,
"public": null,
"type": "tcp"
}
]
}
]GET /api/containers/:id/logs
Response: Plain text with last 10 log lines
GET /health
- React Native
- Expo (v50.0.0)
- React Native Web
- React DOM (for web support)
- Axios
- Node.js
- Express
- Dockerode (Docker API client)
- CORS
- Docker & Docker Compose
- Nginx (Reverse Proxy)
EXPO_DEVTOOLS_LISTEN_ADDRESS=0.0.0.0- Allow external connectionsREACT_NATIVE_PACKAGER_HOSTNAME- Set to your local IP for mobile testing
PORT=4000- Backend server port (default: 4000)
| Service | Internal Port | External Port | Description |
|---|---|---|---|
| Nginx | 80 | 80 | Reverse proxy |
| Backend | 4000 | - | API server (internal) |
| Frontend | 8081 | 8081 | Metro bundler (web) |
| Frontend | 8082 | 8082 | Web server |
| Frontend | 19000-19002 | 19000-19002 | Expo DevTools |
The frontend is configured with volume mounting for hot-reload. Any changes to frontend/App.js will automatically refresh in the browser.
# Make changes to frontend/App.js and watch them reload automatically!docker compose downdocker compose up -d --build- Frontend changes: Edit
frontend/App.jsβ changes auto-reload in browser - Backend changes: Edit
backend/src/index.jsβ restart backend:docker compose restart backend
- Nginx changes: Edit
nginx/nginx.confβ rebuild nginx:docker compose up -d --build nginx
- Add package to
frontend/package.json - Rebuild:
docker compose up -d --build frontend
- Add package to
backend/package.json - Rebuild:
docker compose up -d --build backend
# Clean up and restart
docker compose down
docker compose up -d --build# Find what's using the port
netstat -ano | findstr :8081 # Windows
lsof -i :8081 # Mac/Linux
# Stop the conflicting process or change ports in docker-compose.yml# Check frontend logs
docker logs -f dnmonitor-frontend
# Rebuild frontend
docker compose up -d --build frontend- Ensure Docker Desktop is running
- Check Docker socket is mounted:
/var/run/docker.sock:/var/run/docker.sock
# Check nginx config syntax
docker exec dnmonitor-nginx nginx -t
# View nginx logs
docker logs dnmonitor-nginx- Check API_URL in
frontend/App.jsis set tohttp://localhost/api - Verify backend is running:
docker ps | grep dnmonitor-backend - Test API directly:
curl http://localhost/api/containers
- The application monitors the Docker instance it's running in (Docker-in-Docker)
- Container logs show only the last 10 lines (configurable in
backend/src/index.js) - Nginx serves as a reverse proxy to handle CORS and routing
- Frontend runs in web mode by default (can also run on mobile via Expo Go)
- Volume mounting enables hot-reload without rebuilding containers
- Favicon warnings in logs are harmless and don't affect functionality
- Real-time updates using WebSockets
- Container start/stop/restart functionality
- Resource usage metrics (CPU, Memory)
- Container filtering and search
- Dark mode support
- Export logs functionality
- Multi-host Docker support
- Authentication/Authorization
- Persist settings/preferences
- Container stats visualization
Feel free to fork this project and submit pull requests for any improvements!
This project is open source and available for educational and personal use.
Built with β€οΈ using Docker, React Native, Expo, and Node.js

