Kickstarting Kafka Locally with Docker Compose
đ The hands-on journey to Kafka mastery begins here.
đ The hands-on journey to Kafka mastery begins here.
Kickstarting Kafka Locally with Docker Compose
đ The hands-on journey to Kafka mastery begins here.
đ§ Why Start with Docker?
If youâre learning Apache Kafka, your first battle is just⌠getting the damn thing to run.
Installing Kafka manually can be a painâââZookeeper dependencies, port conflicts, Java versions, memory configs. Ugh.
Instead, weâll use Docker Compose to set up a fully working Apache Kafka cluster with Zookeeper and a slick Kafka UI dashboardâââall in under 5 minutes.
đ ď¸ What Weâll Set Up
- đ Zookeeper (required by Kafka)
- đŚ Apache Kafka (Bitnamiâs official Docker image)
- đ Kafka UI (Browser-based admin tool for topics, messages, offsets)
Weâll build on this stack in future posts, gradually working toward a full event-driven e-commerce system.
đ Why Do We Need Zookeeper?
Kafka uses Zookeeper to:
- Track broker metadata and cluster health
- Elect a controller broker to coordinate partition leadership
- Store configurations and ACLs (in traditional setups)
You can think of Zookeeper as Kafkaâs cluster brainâââresponsible for coordination and consensus between brokers.
đĄ In newer Kafka versions (2.8+), Zookeeper is optional if youâre using KRaft mode (KRaft = Kafka Raft Metadata mode). But for local development and compatibility, Zookeeper is still commonly used.
đ Folder Structure
Your project will begin with this structure:
kafka-mastery/
âââ docker-compose.yml
âââ README.md
âââ .gitignore
âââ src/
âââ main/java/com/ajitem/kafka/
Each future post will build on this codebase. All code lives in one GitHub repo, versioned by tags.
đł The Docker Compose File
Hereâs the minimal docker-compose.yml to boot Kafka, Zookeeper, and Kafka UI locally:
version: '3.8'
services:
zookeeper:
image: bitnami/zookeeper:3.9
container_name: zookeeper
environment:
- ALLOW_ANONYMOUS_LOGIN=yes
ports:
- "2181:2181"
kafka:
image: bitnami/kafka:3.7
container_name: kafka
depends_on:
- zookeeper
environment:
- KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092
- KAFKA_CFG_LISTENERS=PLAINTEXT://:9092
- ALLOW_PLAINTEXT_LISTENER=yes
ports:
- "9092:9092"
kafka-ui:
image: provectuslabs/kafka-ui:latest
container_name: kafka-ui
depends_on:
- kafka
ports:
- "8080:8080"
environment:
- KAFKA_CLUSTERS_0_NAME=local
- KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS=kafka:9092
â
Why Bitnami Images?
 Theyâre fast, lightweight, well-documented, and open-source friendly.
𧪠Running Kafka Locally
Make sure Docker is running, then open your terminal:
git clone https://github.com/ajitems/kafka-mastery.git
cd kafka-mastery
git checkout v0.1.0
docker-compose up
Youâll see Kafka and Zookeeper start up like this:
kafka | [INFO] Kafka started on port 9092
zookeeper| [INFO] binding to port 2181
đ Kafka UI Dashboard
Once your cluster is up, open your browser and go to:

Youâll see a beautiful UI that lets you:
- View brokers and topics
- Create/delete topics
- Inspect messages
- Monitor partitions and consumer groups
â Test It Works
Letâs create a topic via the CLI:
docker compose exec -it kafka kafka-topics.sh \
--create --topic test-topic \
--bootstrap-server localhost:9092

Refresh the Kafka UIâââtest-topic should now appear.
đˇ Git Tag for This Post
You can check out this exact setup using:
git checkout v0.1.0
Full code: github.com/asahasrabuddhe/kafka-mastery/tree/v0.1.0
đ§ What You Learned
â
How to set up Kafka with Docker Compose
â
Why we need Zookeeper
â
How to inspect the cluster with Kafka UI
â
How to create topics via CLI
đ Whatâs Next?
In the next post, weâll:
- Write a Kafka Producer in Java
- Send JSON messages to a topic
- Create a Consumer to read those messages
- View them in Kafka UI
đ Read Part 2: Your First Kafka Producer and Consumer
đ Feedback Welcome
If you found this useful, consider:
- Leaving a comment đŹ
- Following me on LinkedIn
- â Starring the GitHub repo