- docker-compose.yml文件内容如下:
version: '2'
services:
zookeeper:
image: zookeeper:3.5.8
container_name: zookeeper
restart: always
hostname: zookeeper
ports:
- "2181:2181"
kafka:
image: wurstmeister/kafka:2.12-2.5.0
container_name: kafka
hostname: kafka
restart: always
ports:
- "9092:9092"
- "7203:7203"
environment:
KAFKA_ADVERTISED_HOST_NAME: 10.250.115.210
KAFKA_ZOOKEEPER_CONNECT: "10.250.115.210:2181"
- 使用docker-compose安装
docker-compose up -d
- 查看日志
docker logs -f kafka
- 注意事项
其他容器想连接kafka时,最好通过"kafka:9092",即"容器名称:端口号"。