Apache Kafka and zookeeper in an Alpine container.
1.8K
This Docker container allows you to launch instances of Apache Kafka and Apache Zookeeper.
The can be launched in the same container on in a clusterized way.
MODEIt accepts three possible values:
ZOOKEEPER_AND_KAFKA. This mode will launch an instance of zookeeper and another one of kafka in the containerZOOKEEPER. This mode will launch only an instance of zookeeper in the containerKAFKA. This mode will launch only an instance of kafka in the containerZOOKEEPER_PORTMaps to clientPort property. Default value is 2181.
ZOOKEEPER_DATA_DIRMaps to dataDir property. Default value is /tmp/zookeeper
ZOOKEEPER_INIT_LIMITMaps to initLimit property. Default value is 5
ZOOKEEPER_SYNC_LIMITMaps to syncLimit property. Default value is 2
ZOOKEEPER_TICK_TIMEMaps to tickTime property. Default value is 2000
KAFKA_BROKER_IDMaps to broker.id property. Default value is 0. If you create a cluster of kafka brokers this number must not be repeated.
KAFKA_PORTThis will add the entry listeners=PLAINTEXT://$HOSTNAME:$KAFKA_PORT to the kafka properties. Its default value is 9092.
KAFKA_LOG_DIRSMaps to log.dirs property. Default value is /tmp/kafka-logs
KAFKA_NUM_PARTITIONSMaps to num.partitions property. Default value is 1.
KAFKA_AUTO_CREATE_TOPICS_ENABLEMaps to auto.create.topics.enable property. Default value is true.
KAFKA_DEFAULT_REPLICATION_FACTORMaps to default.replication.factor property. Default value is 1.
KAFKA_LOG_RETENTION_HOURSMaps to log.retention.hours property. Default value is 168.
KAFKA_ZOOKEEPER_CONNECTMaps to zookeeper.connect property. Default value is localhost:2181. It accepts a comma-separated list of zookeeper instances in a host:port form.
The default mode for the container is ZOOKEEPER_AND_KAFKA. So, for running an instance with all servers the command is:
docker run -p9092:9092 -p2181:2181 -it --rm --hostname kafka alexsuch/kafka:0.11.0.0
If running locally, and/or don't want to map the kafka entry in your /etc/hosts file, you can run:
docker run -p9092:9092 -p2181:2181 -it --rm --hostname localhost alexsuch/kafka:0.11.0.0
If using docker-compose, here you have an example that achieves the same infrastructure.
There are some docker-compose files in the docker-compose-samples folder.
KAFKA_DEFAULT_REPLICATION_FACTOR is set to 1 so only one node will replicate.KAFKA_DEFAULT_REPLICATION_FACTOR is set to 2, so all brokers will contain replicas of the topics. Besides, the KAFKA_ZOOKEEPER_CONNECT contains the two zookeeper instances addresses.Content type
Image
Digest
Size
118.9 MB
Last updated
about 8 years ago
docker pull alexsuch/kafka:1.1.1