1. 下载
docker pull wurstmeister/kafka //下载命令
docker pull zookeeper
2. 安装zookeeper
docker run -d --name zookeeper-kafka -p 2181:2181 -v /etc/localtime:/etc/localtime zookeeper
3. 安装kafka
docker run -d --name kafka-server2 \
-p 9092:9092 \
-e KAFKA_BROKER_ID=1 \
-e KAFKA_ZOOKEEPER_CONNECT=192.168.0.102:2181 \ #不能localhost
-e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://192.168.0.102:9092 \
-e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 \
-t wurstmeister/kafka