
How to start Kafka using Docker?
Natan Ferreira
- 0
- 22
It’s possible to use Kafka on various operating systems, but here we’ll use Docker on Ubuntu Linux. We need Docker Desktop installed in order to proceed. You can follow this tutorial to install it:
👉 tutorial .
Go to Docker Hub and in the search bar, look for “apache kafka”. This will allow us to download the image needed to create a container.
Hands on


After clicking on the Apache Kafka image, download it by clicking Pull, then go to the Run option.

Set the container name and port, then click Run.

The log should indicate that everything is running properly.

Now, in the Exec tab, we can run commands inside the /opt/kafka
directory.
cd opt
cd kafka
bin/kafka-topics.sh --create --topic my-topic --bootstrap-server localhost:9092 --partitions 3 --replication-factor 1
This way, we can create a topic.
bin/kafka-topics.sh --list --bootstrap-server localhost:9092
Use the following command to list topics.

Conclusion
This is a practical way to run Kafka locally without installing it directly on your operating system.
Author
-
I am a seasoned Full Stack Software Developer with 8+ years of experience, including 6+ years specializing in Java with Spring and Quarkus. My core expertise lies in developing robust RESTful APIs integrated with Cosmos Db, MySQL, and cloud platforms like Azure and AWS. I have extensive experience designing and implementing microservices architectures, ensuring performance and reliability for high-traffic systems. In addition to backend development, I have experience with Angular to build user-friendly interfaces, leveraging my postgraduate degree in frontend web development to deliver seamless and responsive user experiences. My dedication to clean and secure code led me to present best practices to my company and clients, using tools like Sonar to ensure code quality and security. I am a critical thinker, problem solver, and team player, thriving in collaborative environments while tackling complex challenges. Beyond development, I share knowledge through my blog, NatanCode, where I write about Java, Spring, Quarkus, databases, and frontend development. My passion for learning and delivering innovative solutions drives me to excel in every project I undertake.