Skip to content

Instantly share code, notes, and snippets.

@JalalSordo
Last active April 20, 2022 13:52
Show Gist options
  • Select an option

  • Save JalalSordo/d6c8075198bac4f022056f80aaf1ef78 to your computer and use it in GitHub Desktop.

Select an option

Save JalalSordo/d6c8075198bac4f022056f80aaf1ef78 to your computer and use it in GitHub Desktop.
Run Apache Kafka locally with Docker (Windows), the data will remain after restarting the containers, this also features a gui, accessible through : http://localhost:8333/ui, consumers should listen to localhost:9094 in the host machine
docker volume create zookeeper-data-storage
docker volume create zookeeper-txn-logs-storage
docker volume create kafka-data-storage
docker network rm LocalKafkaNetwork
docker network create LocalKafkaNetwork
docker run -d --name zookeeper --hostname zookeeper-host --network LocalKafkaNetwork -p 2181 -v zookeeper-data-storage:/var/lib/zookeeper/data -v zookeeper-txn-logs-storage:/var/lib/zookeeper/log zookeeper
docker run -d --name kafka --hostname kafka-host --network LocalKafkaNetwork -p 9094:9094 -e KAFKA_ZOOKEEPER_CONNECT=zookeeper-host:2181 -e KAFKA_LISTENER_SECURITY_PROTOCOL_MAP=INTERNAL:PLAINTEXT,OUTSIDE:PLAINTEXT -e KAFKA_INTER_BROKER_LISTENER_NAME=INTERNAL -e KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1 -e KAFKA_ADVERTISED_LISTENERS=INTERNAL://kafka-host:9092,OUTSIDE://localhost:9094 -e KAFKA_LISTENERS=INTERNAL://0.0.0.0:9092,OUTSIDE://0.0.0.0:9094 -v kafka-data-storage:/var/lib/kafka/data confluentinc/cp-kafka
docker run -d --name kafka-ui --hostname kafka-ui-host --network LocalKafkaNetwork -p 8333:8333 -e KAFKA_CLUSTERS_0_NAME=local -e KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS=kafka-host:9092 -e SERVER_PORT=8333 provectuslabs/kafka-ui:latest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment