This repository provides everything you need to run Kafka in Docker. It's a patched-up fork of spotify/docker-kafka which seems to be abandoned.
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
First, launch the broker:
docker run -p 2181:2181 -p 9092:9092 --env ADVERTISED_HOST=0.0.0.0 --env ADVERTISED_PORT=9092 kchristidis/kafkaThen, from your localhost, launch a producer and a consumer:
kafka-console-producer.sh --broker-list localhost:9092 --topic testkafka-console-consumer.sh --zookeeper localhost:2181 --topic testNote that the ADVERTISED_HOST ENV var is optional; if not set, Kafka will bind itself on the host's IP, as retrieved via the hostname --ip-address command.
- Public build: https://registry.hub.docker.com/u/kchristidis/kafka/
- Build from source:
docker build -t kchristidis/kafka kafka/
- Add TLS support