#示例
version: '2'
services:
zookeeper:
image: wurstmeister/zookeeper ## 镜像
# ports:
# - "2181:2181" ## 对外暴露的端口号
kafka:
image: wurstmeister/kafka ## 镜像
# ports:
# - "9092:9092"
environment:
KAFKA_ADVERTISED_HOST_NAME: kafka ## 修改:宿主机IP
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181 ## 卡夫卡运行是基于zookeeper的
depends_on:
- zookeeper
kafka-manager:
image: sheepkiller/kafka-manager ## 镜像:开源的web管理kafka集群的界面
environment:
ZK_HOSTS: zookeeper:2181 ## 修改:宿主机IP
ports:
- "9000:9000" ## 暴露端口
depends_on:
- kafka
# consumer
## 进入容器
docker exec -it kafka_kafka_1 /bin/sh
## 进入容器后执行,等待消息
kafka-console-consumer.sh --bootstrap-server kafka:9092 --topic demo --from-beginning
# producer
## 进入容器
docker exec -it kafka_kafka_1 /bin/sh
## 进入容器后执行
kafka-console-producer.sh --broker-list kafka:9092 --topic demo
## 然后试着输入一些文本来发送消息,查看消息接收
--jars `ls /home/hdfs/test/gobblin-dist/lib/* | tr "\n" ","`