Container Status Monitoring
Monitor the status of your Docker containers to ensure the application is running properly.Check running containers
Use the Expected output:
docker ps command to view all running containers:The container name
miniproject is defined in docker-compose.yml:7. Verify the STATUS column shows “Up” to confirm the container is running.Application Logs
View real-time logs from the application container to monitor activity and debug issues.View Container Logs
Follow Logs in Real-Time
To monitor logs as they’re generated:Press
Ctrl+C to stop following logs. The -f flag is similar to tail -f and continuously streams new log entries.View Last N Lines
To see only the most recent log entries:Logs with Timestamps
Include timestamps for better debugging:Application Health Checks
Verify that your application is responding correctly to requests.Test Backend Endpoint
Check if the Express server is responding on port 5000:This endpoint is defined in
server/index.js:7-9. A successful response confirms the backend is running and accessible.Check Response Headers
View complete HTTP response including headers:Automated Health Check Script
Create a simple health check script:health-check.sh
Resource Monitoring
Monitor CPU, memory, and network usage of your containers.Real-Time Resource Usage
Monitor these metrics to identify performance issues:
- CPU %: Should typically be low for this application
- MEM USAGE: Node.js applications typically use 40-100MB for small apps
- NET I/O: Increases with traffic
Resource Usage (One-Time)
For a single snapshot without continuous updates:Monitor All Containers
View stats for all running containers:Jenkins Build Monitoring
Monitor Jenkins pipeline builds to ensure successful deployments.Check Build Status
- Access Jenkins dashboard at
http://localhost:8080(or your Jenkins URL) - Navigate to your pipeline job
- View the latest build status and console output
Pipeline Stages
The Jenkins pipeline defined inJenkinsfile includes these stages:
Monitor Build Logs
Check Jenkins console output for:- Successful checkout from Git
- Docker build completion
- Container startup confirmation
- Success message: “Deployment completed successfully!” (
Jenkinsfile:33) - Failure message: “Build or deployment failed!” (
Jenkinsfile:36)
Container Inspection
Get detailed information about the container configuration.Inspect Container
- Network settings and IP address
- Port mappings (5000:5000)
- Environment variables
- Mount points
- Resource limits
View Specific Information
Extract specific fields using--format:
Docker Compose Monitoring
When using docker-compose, use these commands:View Service Status
View Service Logs
Follow Compose Logs
The service name
app is defined in docker-compose.yml:3. This corresponds to the miniproject container.Monitoring Best Practices
Set up automated health checks
Set up automated health checks
Configure Docker health checks in your
Dockerfile or docker-compose.yml to automatically monitor application health:docker-compose.yml
Use log rotation
Use log rotation
Prevent logs from consuming too much disk space by configuring log rotation:
Monitor disk usage
Monitor disk usage
Regularly check Docker disk usage to prevent space issues:Clean up unused resources:
Set resource limits
Set resource limits
Prevent containers from consuming excessive resources:
docker-compose.yml