亲测可用
新建文件docker-compose.yml
version: '2'
services:
zoo:
image: wurstmeister/zookeeper
restart: unless-stopped
hostname: zoo
ports:
- "2181:2181"
container_name: zookeeper
kafka:
image: wurstmeister/kafka
ports:
- "9092:9092"
environment:
KAFKA_ADVERTISED_HOST_NAME: 9.134.5.240 ## 修改:宿主机IP
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://9.134.5.240:19092 ## 修改:宿主机IP
KAFKA_ZOOKEEPER_CONNECT: "zoo:2181"
KAFKA_ADVERTISED_PORT: 9092
KAFKA_BROKER_ID: 1
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
depends_on:
- zoo
container_name: kafka
kafka-manager:
image: sheepkiller/kafka-manager ## 镜像:开源的web管理kafka集群的界面
environment:
ZK_HOSTS: zoo:2181 ## 修改:宿主机IP
ports:
- "9000:9000" ## 暴露端口
运行docker-compose up -d即可