Kafka + Admin UI (Kafdrop) for Local Development with Docker Compose
Today I was looking for a quick and dirty Apache Kafka setup for local development. After Kafka was up and running, I wanted a simple admin interface to manage Kafka. So I thought I’d share it with everyone who needs to setup Kafka quickly to test something out and don’t want to spend a lot of time on setting everything up.
Talk is easy, show me the code!
Before we get started, check if your machine meets the following requirements:
- Docker installed and running;
- docker-compose installed and working;
- A fully working brain
So, where is it? I’m in a hurry!!
Here you are!
But, but, how do I use it?
Worry not my fellow developer, its very simple! Just follow the steps below:
- Download the file (docker-compose.yml) to a folder in your computer.
- Open a terminal window and
cd
into the folder you saved the file. - Execute the
docker-compose up
command and watch the magic happens! (It may take a while on the first time, because Docker will download all required images)
It’s running, but how do I access it?
After running docker-compose up
in the same folder where you downloaded the file above, three things will happen:
- Zookeeper will start and bind to the port 2181
- Kafka will start after Zookeeper, and bind to the port 9092
- Kafdrop will start after Kafka, and bind to the port 9100 on your computer
So if everything went right, you can see the Kafdrop UI running on http://localhost:9100. You should see something like this:
After this it’s up to you to discover the features of Kafka and play with it. If you need to connect your application with the cluster, the host/port combination will be: localhost:9092.
Customization & final thoughts
I just want to make it clear that this is just a starting point for new Kafka developers. I’m by no means a Kafka/Docker expert, but this is what worked for me.
If you need (you probably will) more fined grained control over the settings of any of the applications on the compose file, I strongly recommend you to look in their respective DockerHub/Github pages. I will leave the pages of the repos used below.
I hope this small snipped could help you start your next application using this amazing tool, Apache Kafka!
Many thanks to the creators of both of these awesome docker images!