tree: 0d750d348bc2f5792b9a54661eb3a5944309c53c [path history] [tgz]
  1. kafka/
  2. kafkaproxy/
  3. README.md
integrationtest/docker/kafka/README.md

Kafka in Docker

This is a fork spotify/kafka image. We decided to make it, because the project does not maintain proper tagging. For now our tests focus on Kafka 0.8.x, so here is a version that supports Kafka 0.8.x. For latest version of kafka image go to the original project.

This repository provides everything you need to run Kafka in Docker.

For convenience also contains a packaged proxy that can be used to get data from a legacy Kafka 7 cluster into a dockerized Kafka 8.

Why?

The main hurdle of running Kafka in Docker is that it depends on Zookeeper. Compared to other Kafka docker images, this one runs both Zookeeper and Kafka in the same container. This means:

  • No dependency on an external Zookeeper host, or linking to another container
  • Zookeeper and Kafka are configured to work together out of the box

Run

docker run -p 2181:2181 -p 9092:9092 --env ADVERTISED_HOST=`docker-machine ip \`docker-machine active\`` --env ADVERTISED_PORT=9092 grubykarol/kafka
export KAFKA=`docker-machine ip \`docker-machine active\``:9092
kafka-console-producer.sh --broker-list $KAFKA --topic test
export ZOOKEEPER=`docker-machine ip \`docker-machine active\``:2181
kafka-console-consumer.sh --zookeeper $ZOOKEEPER --topic test

Running the proxy

Take the same parameters as the grubykarol/kafka image with some new ones:

  • CONSUMER_THREADS - the number of threads to consume the source kafka 7 with
  • TOPICS - whitelist of topics to mirror
  • ZK_CONNECT - the zookeeper connect string of the source kafka 7
  • GROUP_ID - the group.id to use when consuming from kafka 7
docker run -p 2181:2181 -p 9092:9092 \
    --env ADVERTISED_HOST=`boot2docker ip` \
    --env ADVERTISED_PORT=9092 \
    --env CONSUMER_THREADS=1 \
    --env TOPICS=my-topic,some-other-topic \
    --env ZK_CONNECT=kafka7zookeeper:2181/root/path \
    --env GROUP_ID=mymirror \
    grubykarol/kafkaproxy

In the box

  • grubykarol/kafka

    The docker image with both Kafka and Zookeeper. Built from the kafka directory.

  • grubykarol/kafkaproxy

    The docker image with Kafka, Zookeeper and a Kafka 7 proxy that can be configured with a set of topics to mirror.

Public Builds

https://registry.hub.docker.com/u/grubykarol/kafka/

https://registry.hub.docker.com/u/grubykarol/kafkaproxy/

Build from Source

docker build -t grubykarol/kafka kafka/
docker build -t grubykarol/kafkaproxy kafkaproxy/

Todo

  • Not particularily optimzed for startup time.
  • Better docs