docker-compose-files/kafka/docker-compose.yaml

97 lines
2.7 KiB
YAML
Raw Normal View History

2017-09-15 13:31:23 +08:00
# The minimal kafka service
# github.com/yeasy/docker-compose-files
2020-01-31 07:26:40 +08:00
# * zk: zk node for kafka, 0, 1, 2
2017-09-15 13:31:23 +08:00
# * kafka: kafka service, will default to connect to zookeeper
# * cli: client to test kafka service
2020-02-13 02:28:10 +08:00
version: '3'
2017-09-15 13:31:23 +08:00
services:
2020-01-31 07:26:40 +08:00
zookeeper1:
2020-01-17 06:17:17 +08:00
image: yeasy/kafka:latest
2020-01-31 07:26:40 +08:00
container_name: zookeeper1
hostname: zookeeper1
ports:
- "2182:2181" # zk connection port
environment:
- ZK_ID=1 # when bootup, will read this and update the /tmp/zookeeper/myid file
2020-02-13 02:28:10 +08:00
#volumes:
#- ${PWD}/zookeeper1:/tmp/zookeeper
2020-01-31 07:26:40 +08:00
command: bash -c 'bash /tmp/start_zk.sh'
zookeeper2:
image: yeasy/kafka:latest
container_name: zookeeper2
hostname: zookeeper2
ports:
- "2183:2181" # zk connection port
environment:
- ZK_ID=2 # when bootup, will read this and update the /tmp/zookeeper/myid file
2020-02-13 02:28:10 +08:00
#volumes:
# - ${PWD}/zookeeper2:/tmp/zookeeper
2020-01-31 07:26:40 +08:00
command: bash -c 'bash /tmp/start_zk.sh'
zookeeper3:
image: yeasy/kafka:latest
container_name: zookeeper3
hostname: zookeeper3
2017-09-15 13:31:23 +08:00
ports:
- "2181:2181" # zk connection port
2020-01-31 07:26:40 +08:00
environment:
- ZK_ID=3 # when bootup, will read this and update the /tmp/zookeeper/myid file
2020-02-13 02:28:10 +08:00
#volumes:
# - ${PWD}/zookeeper3:/tmp/zookeeper
2017-09-15 13:31:23 +08:00
command: bash -c 'bash /tmp/start_zk.sh'
2020-01-17 06:17:17 +08:00
kafka0: # kafka service
image: yeasy/kafka:latest
container_name: kafka0
hostname: kafka0
2017-09-15 13:31:23 +08:00
ports:
- "9092:9092"
2020-01-17 06:17:17 +08:00
environment:
- KAFKA_BROKER_ID=0 # when bootup, will read this and update the server.properties
depends_on:
2020-01-31 07:26:40 +08:00
- zookeeper3
- zookeeper1
- zookeeper2
command: bash -c 'sleep 2; bash /tmp/start_kafka.sh'
2020-01-17 06:17:17 +08:00
kafka1: # kafka service
image: yeasy/kafka:latest
container_name: kafka1
hostname: kafka1
ports:
- "9093:9092"
environment:
- KAFKA_BROKER_ID=1 # when bootup, will read this and update the server.properties
depends_on:
2020-01-31 07:26:40 +08:00
- zookeeper1
- zookeeper2
- zookeeper3
command: bash -c 'sleep 2; bash /tmp/start_kafka.sh'
2020-01-17 06:17:17 +08:00
kafka2: # kafka service
image: yeasy/kafka:latest
container_name: kafka2
hostname: kafka2
ports:
- "9094:9092"
environment:
- KAFKA_BROKER_ID=2 # when bootup, will read this and update the server.properties
2017-09-15 13:31:23 +08:00
depends_on:
2020-01-31 07:26:40 +08:00
- zookeeper3
- zookeeper1
- zookeeper2
command: bash -c 'sleep 2; bash /tmp/start_kafka.sh'
2017-09-15 13:31:23 +08:00
cli: # used for testing kafka cmds, see /tmp/*.sh
2020-01-17 06:17:17 +08:00
image: yeasy/kafka:latest
2017-09-15 13:31:23 +08:00
container_name: cli
hostname: cli
environment:
2020-01-31 07:26:40 +08:00
- ZK_HOST=zookeeper1 # zk host to connect to
- KAFKA_HOST=kafka0 # customized the kafka broker to send
2020-01-17 06:17:17 +08:00
command: bash -c 'while true; do sleep 20200116; done'