https://github.com/johnsonlee/docker-kafka
https://github.com/johnsonlee/docker-kafka
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/johnsonlee/docker-kafka
- Owner: johnsonlee
- License: apache-2.0
- Created: 2021-08-21T12:41:12.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2021-12-18T12:59:51.000Z (over 4 years ago)
- Last Synced: 2025-01-27T06:15:04.468Z (over 1 year ago)
- Language: JavaScript
- Homepage: https://hub.docker.com/repository/docker/johnsonlee/kafka
- Size: 24.4 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Getting Started
## Create Network
```bash
docker network create -d bridge kafka-cluster
```
## Launch ZooKeeper
```bash
docker run -it --rm -w=/opt/kafka-2.8.0 --network=kafka-cluster --name zk \
-p 2181:2181 \
johnsonlee/kafka:2.8.0 \
bin/zookeeper-server-start.sh config/zookeeper.properties
```
## Launch Kafka
```bash
docker run -it --rm -w=/opt/kafka-2.8.0 --network=kafka-cluster --name kafka \
-p 9092:9092 \
-v "$(pwd)"/config:/opt/kafka-2.8.0/config \
johnsonlee/kafka:2.8.0 \
bin/kafka-server-start.sh config/server.properties
```
## Create Topic
```bash
docker run -it --rm -w=/opt/kafka-2.8.0 --network=kafka-cluster \
johnsonlee/kafka:2.8.0 \
bin/kafka-topics.sh \
--create \
--topic quickstart-events \
--bootstrap-server kafka:9092
```
## Write Events
Launching an interactive console producer by executing the following command:
```bash
docker run -it --rm -w=/opt/kafka-2.8.0 --network=kafka-cluster \
johnsonlee/kafka:2.8.0 \
bin/kafka-console-producer.sh \
--topic quickstart-events \
--bootstrap-server kafka:9092
```
After the command promote `>` show in the console, then you can write events (one message per line)
## Read Events
Launching a console consumer by executing the following command:
```bash
docker run -it --rm -w=/opt/kafka-2.8.0 --network=kafka-cluster \
johnsonlee/kafka:2.8.0 \
bin/kafka-console-consumer.sh \
--topic quickstart-events \
--from-beginning \
--bootstrap-server kafka:9092
```
After you write event through the interactive console producer, the event can be received by the console consumer immediately.
## Using K6
### Create Topic for K6
```bash
docker run -it --rm -w=/opt/kafka-2.8.0 --network=kafka-cluster \
johnsonlee/kafka:2.8.0 \
bin/kafka-topics.sh \
--create \
--topic k6 \
--bootstrap-server kafka:9092
```
### Run K6
```bash
docker run -it --rm --network=kafka-cluster loadimpact/k6 run \
--logformat=raw \
--out kafka=brokers=kafka:9092,topic=k6,format=json \
-