A Docker Compose configuration for running Apache Kafka with Zookeeper and Kafbat UI for easy cluster management and monitoring.
9092: External access (use this from your host machine)29092: Internal Docker network communicationStart the services:
docker-compose up -d
Check service status:
docker-compose ps
Access Kafbat UI: Open your browser and navigate to http://localhost:8080
View logs:
docker-compose logs -f
The UI expects a configuration file at ./kui/config.yml. Create this file to define your Kafka clusters and connection settings.
Example kui/config.yml:
kafka:
clusters:
- name: local
bootstrapServers: kafka:29092
Use connection string: localhost:9092
Use connection string: kafka:29092
Stop all services:
docker-compose down
Stop and remove volumes (⚠️ deletes all Kafka data):
docker-compose down -v
Restart services:
docker-compose restart
View Kafka logs:
docker-compose logs -f kafka
Kafka data is persisted in the kafka_data Docker volume, ensuring your topics and messages survive container restarts.
docker-compose ps./kui/config.yml exists and is properly formattedrestart: unless-stopped for automatic recoveryservices:
zookeeper:
image: confluentinc/cp-zookeeper:7.6.1
container_name: zookeeper
restart: unless-stopped
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
ports:
- "2181:2181"
kafka:
image: confluentinc/cp-kafka:7.6.1
container_name: kafka
restart: unless-stopped
depends_on:
- zookeeper
ports:
- "9092:9092" # External access for remote clients (n8n)
- "29092:29092" # Internal access within Docker network
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092,PLAINTEXT_INTERNAL://0.0.0.0:29092
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://<YOUR_HOST_IP>:9092,PLAINTEXT_INTERNAL://kafka:29092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_INTERNAL:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT_INTERNAL
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_LOG_RETENTION_HOURS: 168
KAFKA_LOG_DIRS: /var/lib/kafka/data
volumes:
- kafka_data:/var/lib/kafka/data
kafbat-ui:
image: ghcr.io/kafbat/kafka-ui:latest
container_name: kafbat-ui
restart: unless-stopped
depends_on:
- kafka
- zookeeper
ports:
- "8080:8080"
environment:
DYNAMIC_CONFIG_ENABLED: 'true'
volumes:
- ./kui/config.yml:/etc/kafkaui/dynamic_config.yaml
volumes:
kafka_data: