Apache Kafka Docker Image Example

Apache Kafka is a fault tolerant publish-subscribe streaming platform that lets you process streams of records as they occur. This post is a step by step guide of how to build a simple Apache Kafka Docker image. The original Dockerfile can be found here: https://github.com/nsonntag/docker-images/tree/master/kafka-quickstart.

The Dockerfile

This Dockerfile is very simple. It installs Java and wget, downloads and install Kafka, and starts the Zookeeper and Kafka servers (as part of another script).

Starting Zookeeper and Kafka

In the Dockerfile above you can see CMD ["/scripts/start-kafka.sh"]. This command is used to start both Zookeeper and Kafka servers. Here are the contents of start-kafka.sh:

Building the Kafka Image

Once we have our Dockerfile and start-kafka.sh files ready, we can build this docker image. Here is an example of building this image (in the same directory as our Dockerfile) as kafka-quickstart version 0.10.2.0.

Starting a Kafka Docker Container

Once the image is built we can create and run a new Kafka Docker container. The command below will create a container from our image and name it kafka-quickstart:

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">