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

109 lines
3.3 KiB
YAML

# The minimal kafka service
# github.com/yeasy/docker-compose-files
# * zk: zk node for kafka, 0, 1, 2
# * kafka: kafka service, will default to connect to zookeeper
# * cli: client to test kafka service
version: '3'
services:
zookeeper1:
image: yeasy/zookeeper:latest
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
- ZK_HOST1=zookeeper1
- ZK_HOST2=zookeeper2
- ZK_HOST3=zookeeper3
#volumes:
#- ${PWD}/zookeeper1:/tmp/zookeeper
command: bash -c 'bash /tmp/start_zk.sh'
zookeeper2:
image: yeasy/zookeeper: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
- ZK_HOST1=zookeeper1
- ZK_HOST2=zookeeper2
- ZK_HOST3=zookeeper3
#volumes:
# - ${PWD}/zookeeper2:/tmp/zookeeper
command: bash -c 'bash /tmp/start_zk.sh'
zookeeper3:
image: yeasy/zookeeper:latest
container_name: zookeeper3
hostname: zookeeper3
ports:
- "2181:2181" # zk connection port
environment:
- ZK_ID=3 # when bootup, will read this and update the /tmp/zookeeper/myid file
- ZK_HOST1=zookeeper1
- ZK_HOST2=zookeeper2
- ZK_HOST3=zookeeper3
#volumes:
# - ${PWD}/zookeeper3:/tmp/zookeeper
command: bash -c 'bash /tmp/start_zk.sh'
kafka0: # kafka service
image: yeasy/kafka:latest
container_name: kafka0
hostname: kafka0
ports:
- "9092:9092"
environment:
- KAFKA_BROKER_ID=0 # when bootup, will read this and update the server.properties
- ZK_URL=zookeeper1:2181,zookeeper2:2181,zookeeper3:2181 # when bootup, will read this and update the server.properties
depends_on:
- zookeeper3
- zookeeper1
- zookeeper2
command: bash -c 'sleep 5; bash /tmp/start_kafka.sh'
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
- ZK_URL=zookeeper1:2181,zookeeper2:2181,zookeeper3:2181 # when bootup, will read this and update the server.properties
depends_on:
- zookeeper1
- zookeeper2
- zookeeper3
command: bash -c 'sleep 5; bash /tmp/start_kafka.sh'
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
- ZK_URL=zookeeper1:2181,zookeeper2:2181,zookeeper3:2181 # when bootup, will read this and update the server.properties
depends_on:
- zookeeper3
- zookeeper1
- zookeeper2
command: bash -c 'sleep 5; bash /tmp/start_kafka.sh'
cli: # used for testing kafka cmds, see /tmp/*.sh
image: yeasy/kafka:latest
container_name: cli
hostname: cli
environment:
- ZK_HOST=zookeeper1 # zk host to connect to
- KAFKA_HOST=kafka0 # customized the kafka broker to send
command: bash -c 'while true; do sleep 20200116; done'