Create Kafka 2.0 with Docker

I don’t find an all-in-one image for Kafka 2.0+ in https://hub.docker.com, the only one from spotify/kafka supports Kafka 0.10 only which is an very old version.

In github repository, a modified version is provided in #92. You can download and follow the steps to create your own image. I publish one image with Kafka 2.0.0 in dockerhub, and start an Kafka 2.0.0 instance quickly.

  1. docker image
    The URL is https://hub.docker.com/r/mingmin/kafka;

  2. start an instance with docker cli

    docker run -p 2181:2181 -p 9092:9092 --env ADVERTISED_HOST=localhost mingmin/kafka:latest

ADVERTISED_HOST is required, I push localhost here for local test only. Use your accessible host name to expose the Kafka instance.

We’re done now, a Kafka 2.0.0 instance(broker localhost:9092, zookeeper localhost:2181) is ready to use.

install Docker in Mac

Docker is an open-source project that automates the deployment of applications inside software containers. Docker CE(Community Edition) for Mac is an easy-to-install desktop app for building, debugging, and testing Dockerized apps on a Mac.

1. system requirement

Docker for Mac works on OS X El Capitan 10.11 and newer macOS releases.

2. download Docker installation package

The stable Docker image for Mac can be downloaded with link.

3. install

Double-click Docker.dmg in your download folder, and follow the installation process.

After the installation is completed, goto Launchpad and start Docker by clicking the icon. After that, the whale in the top status bar shows that Docker is running, and accessible from a terminal.

4. test and run

Open a terminal, and try out some Docker commands to make sure it’s properly installed.

  • Run docker version to check that you have the latest release installed.

  • Run docker run hello-world to verify that Docker is pulling images and running as expected.