# MongoDB Health Check Fix ## Problem The MongoDB container was failing health checks with the original configuration: ```yaml healthcheck: test: ['CMD', 'mongosh', '--eval', 'db.adminCommand.ping()'] start_period: 10s # Too short! ``` ## Root Causes 1. **start_period too short**: 10s isn't enough for MongoDB to initialize, especially on first start 2. **Command format**: The healthcheck needs proper output handling ## Solution Updated healthcheck in docker-compose.dev.yml: ```yaml healthcheck: test: | mongosh --eval "db.adminCommand('ping').ok" --quiet interval: 10s timeout: 5s retries: 5 start_period: 40s # Increased from 10s to 40s ``` ## Changes Made - ✅ Increased `start_period` from 10s to 40s (gives MongoDB time to initialize) - ✅ Simplified the healthcheck command to use shell format - ✅ Added `--quiet` flag to suppress verbose output ## How to Apply On your server: ```bash # Pull the latest changes git pull origin main # Stop and remove existing containers docker compose -f docker-compose.dev.yml down -v # Start fresh docker compose -f docker-compose.dev.yml up -d # Watch the logs docker compose -f docker-compose.dev.yml logs -f mongodb ``` ## Verify Health Check ```bash # Check container health docker ps --format "table {{.Names}} {{.Status}}" # Check health status specifically docker inspect normogen-mongodb-dev --format='{{.State.Health.Status}}' ``` Expected output: `healthy`