Place in in same root dir having docker-compose.yml
- This should set up the Zookeeper and Kafka Broker in your local environment
docker-compose up
- Run this below command
docker ps
- You should be below containers up and running in local
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fb28f7f91b0e confluentinc/cp-server:7.1.0 "/etc/confluent/dock…" 50 seconds ago Up 49 seconds 0.0.0.0:9092->9092/tcp, 0.0.0.0:9101->9101/tcp broker
d00a0f845a45 confluentinc/cp-zookeeper:7.1.0 "/etc/confluent/dock…" 50 seconds ago Up 49 seconds 2888/tcp, 0.0.0.0:2181->2181/tcp, 3888/tcp zookeeper
- This command should take care of logging in to the Kafka container.
docker exec -it broker bash
- Command to produce messages in to the Kafka topic.
kafka-console-producer --broker-list localhost:9092 --topic greetings
- This command should take care of logging in to the Kafka container.
docker exec -it broker bash
- Command to consume messages from the Kafka topic.
kafka-console-consumer --bootstrap-server localhost:9092 --topic greetings-output