This Docker Compose configuration sets up a complete Apache Druid cluster with all necessary components for real-time analytics and data ingestion.
This setup includes:
- Apache Druid 27.0.0 - Complete cluster with all services
- PostgreSQL - Metadata storage
- Apache Zookeeper - Coordination service
- Apache Kafka - Streaming data platform
- PostgreSQL (
druid_postgres) - Stores Druid metadata on port 5432 - Zookeeper (
druid_zookeeper) - Manages cluster coordination on port 2181 - Kafka (
cp-kafka) - Message streaming platform on ports 29092-29093
- Coordinator (
druid_coordinator) - Manages data availability and replication (port 8081) - Broker (
druid_broker) - Handles queries from external clients (port 8082) - Historical (
druid_historical) - Serves historical data segments (port 8083) - MiddleManager (
druid_middlemanager) - Manages data ingestion tasks (port 8091, 8100-8105) - Router (
druid_router) - Routes requests to appropriate services (port 8888)
- Docker and Docker Compose installed
- Create a
.env-druidfile with Druid configuration (see Configuration section) - Ensure ports 2181, 5432, 8081-8083, 8091, 8100-8105, 8888, 29092-29093 are available
- Clone this repository and navigate to the directory
- Create the required environment file:
touch .env-druid
- Start the cluster:
docker-compose up -d
- Wait for all services to be healthy (this may take a few minutes)
- Access the Druid console at: http://localhost:8888
Create a .env-druid file with your Druid configuration. Example:
# Database
druid_metadata_storage_type=postgresql
druid_metadata_storage_connector_connectURI=jdbc:postgresql://postgres:5432/druid
druid_metadata_storage_connector_user=druid
druid_metadata_storage_connector_password=FoolishPassword
# Zookeeper
druid_zk_service_host=zookeeper:2181
# Extensions
druid_extensions_loadList=["druid-histogram", "druid-datasketches", "druid-lookups-cached-global", "postgresql-metadata-storage", "druid-kafka-indexing-service"]
# Logging
druid_log_level=INFO
# Java heap settings (adjust based on your system)
DRUID_XMX=1g
DRUID_XMS=1g| Service | Port | Description |
|---|---|---|
| PostgreSQL | 5432 | Database access |
| Zookeeper | 2181 | Coordination service |
| Coordinator | 8081 | Cluster management UI |
| Broker | 8082 | Query endpoint |
| Historical | 8083 | Historical data service |
| MiddleManager | 8091 | Task management |
| MiddleManager Tasks | 8100-8105 | Individual task ports |
| Router | 8888 | Main Druid Console |
| Kafka | 29092 | Internal broker access |
| Kafka External | 29093 | External broker access |
The following Docker volumes ensure data persistence:
metadata_data- PostgreSQL database filesdruid_shared- Shared Druid segments and logscoordinator_var,broker_var,historical_var,middle_var,router_var- Service-specific data
- Primary Interface: http://localhost:8888 (Router - recommended)
- Coordinator UI: http://localhost:8081
- Broker Queries: http://localhost:8082
- Internal: Connect to
kafka:9092from within Docker network - External: Connect to
localhost:29092from host machine - External with custom IP: Set
EXT_IPenvironment variable
curl -X POST 'http://localhost:8082/druid/v2/sql' \
-H 'Content-Type: application/json' \
-d '{"query":"SELECT * FROM INFORMATION_SCHEMA.TABLES"}'This configuration is designed for development and testing. For production:
- Security: Change default passwords and add authentication
- Resources: Adjust heap sizes in
.env-druid - Persistence: Use external databases for metadata storage
- Monitoring: Add monitoring and alerting
- Load Balancing: Consider multiple instances of broker/historical nodes
- Services not starting: Check if ports are already in use
- Out of memory errors: Increase Docker memory allocation or reduce heap sizes
- Connection refused: Wait for all dependencies to be fully ready
# Check service logs
docker-compose logs -f [service_name]
# Restart a specific service
docker-compose restart [service_name]
# Check service health
docker-compose psOnce running, you can ingest data via:
- Kafka: Stream data to Kafka topics and create Kafka ingestion specs
- Batch: Upload files through the web console
- API: Use the ingestion API endpoints
Refer to the Apache Druid documentation for detailed ingestion guides.
# Stop all services
docker-compose down
# Stop and remove volumes (WARNING: This deletes all data)
docker-compose down -v