1. ymal 文件
version: "3"
services:
zookeeper:
image: 'bitnami/zookeeper:latest'
ports:
- '2181:2181'
environment:
- ALLOW_ANONYMOUS_LOGIN=yes
restart: always
networks:
- exhibiton
kafka:
image: 'bitnami/kafka:latest'
ports:
- '9092:9092'
environment:
- KAFKA_BROKER_ID=1
- KAFKA_CFG_LISTENERS=PLAINTEXT://:9092
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://127.0.0.1:9092
- KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181
- ALLOW_PLAINTEXT_LISTENER=yes
restart: always
depends_on:
- zookeeper
2. 启动服务
[root@gujia-test01 kafka]# docker-compose ps
Name Command State Ports
-----------------------------------------------------------------------------------------------------------------
kafka_kafka_1 /opt/bitnami/scripts/kafka ... Up 0.0.0.0:9092->9092/tcp
kafka_zookeeper_1 /opt/bitnami/scripts/zooke ... Up 0.0.0.0:2181->2181/tcp, 2888/tcp, 3888/tcp, 8080/tcp
3. 测试
见 《单机版kafka部署》 测试部分