Dockerizing a Kafka Streams app

Maciej Szymczyk
The Startup
2 min readMay 12, 2020

--

Docker images are easy to use. We do not need to install a specific version of the environment, libraries or other dependencies. Everything should be enclosed in an abstraction called a container. We can run and scale them in Docker Swarm or Kubernetes. In this post, we will deal with the dockerization of the Kafka Streams application written in the previous story.

Changes in pom.xml

In the original version of the project, creating a package with the mvn package command generated a thin jar. Thin jar requires dependency delivery to run it. It is more convenient in this case to create a fat jar so that the complete application is in one file.

Changes in the Kafka Streams application

The application has hard-coded topic names, application id and address of the broker. To avoid compiling a new version with each change, I’ve created a mechanism based on environment variables. This is a fairly common way to configure containers in Docker.

--

--

Maciej Szymczyk
The Startup

Software Developer, Big Data Engineer, Blogger (https://wiadrodanych.pl), Amateur Cyclists & Triathlete, @maciej_szymczyk