因为kafka依赖zookeeper所以先安装zookeeper [参考]
docker pull bitnami/kafka
docker run -d --name kafka -p 9092:9092 -e KAFKA_BROKER_ID=0 -e ALLOW_PLAINTEXT_LISTENER=yes -e KAFKA_ZOOKEEPER_CONNECT=192.168.220.100:2181 -e KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://192.168.220.100:9092 -e KAFKA_LISTENERS=PLAINTEXT://0.0.0.0:9092 -v /docker/kafka/logs:/opt/bitnami/kafka/logs -v /docker/kafka/data:/bitnami/kafka/data -t bitnami/kafka
安装管理工具
docker pull sheepkiller/kafka-manager
docker run --name kafka-manager -d -p 9000:9000 -e ZK_HOSTS="192.168.220.100:2181" sheepkiller/kafka-manager
访问地址:http://192.168.220.100:9000/
生产者 消费者 java示例 [源码]