docker-compose.yml
5.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
version: '3'
services:
zookeeper-kafka:
image: confluentinc/cp-zookeeper:latest
ports:
- '2181:2181'
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
healthcheck:
# fake healthcheck just to have one to simplify status check
test: ['CMD', 'date']
interval: 10s
timeout: 5s
retries: 5
# docs at: https://registry.hub.docker.com/r/wurstmeister/kafka
kafka-broker-1:
image: wurstmeister/kafka:latest
restart: always
depends_on:
- zookeeper-kafka
ports:
- '9092:9092'
volumes:
# It's the only way to deal with Kafka non-static exposed ports to host
# See: https://github.com/wurstmeister/kafka-docker/blob/master/start-kafka.sh#L65-L76
- /var/run/docker.sock:/var/run/docker.sock
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: 'zookeeper-kafka:2181'
PORT_COMMAND: 'docker port $$(hostname) 9092/tcp | cut -d: -f2'
KAFKA_LISTENERS: 'LISTENER_INTERNAL://kafka-broker-1:29092,LISTENER_HOST://:9092'
KAFKA_ADVERTISED_LISTENERS: LISTENER_INTERNAL://kafka-broker-1:29092,LISTENER_HOST://localhost:_{PORT_COMMAND}
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: LISTENER_INTERNAL:PLAINTEXT,LISTENER_HOST:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: LISTENER_INTERNAL
KAFKA_JMX_OPTS: "-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=kafka-broker-1 -Dcom.sun.management.jmxremote.rmi.port=1099"
JMX_PORT: 1099
KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'true'
KAFKA_CREATE_TOPICS: 'test:3:3'
healthcheck:
test:
[
'CMD',
'/opt/kafka/bin/kafka-topics.sh',
'--list',
'--bootstrap-server',
'kafka-broker-1:29092',
]
interval: 10s
timeout: 5s
retries: 5
kafka-broker-2:
image: wurstmeister/kafka:latest
restart: always
depends_on:
- zookeeper-kafka
ports:
- '9093:9092'
volumes:
# It's the only way to deal with Kafka non-static exposed ports to host
# See: https://github.com/wurstmeister/kafka-docker/blob/master/start-kafka.sh#L65-L76
- /var/run/docker.sock:/var/run/docker.sock
environment:
KAFKA_BROKER_ID: 2
KAFKA_ZOOKEEPER_CONNECT: 'zookeeper-kafka:2181'
PORT_COMMAND: 'docker port $$(hostname) 9092/tcp | cut -d: -f2'
KAFKA_LISTENERS: 'LISTENER_INTERNAL://kafka-broker-2:29092,LISTENER_HOST://:9092'
KAFKA_JMX_OPTS: "-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=kafka-broker-2 -Dcom.sun.management.jmxremote.rmi.port=1099"
JMX_PORT: 1099
KAFKA_ADVERTISED_LISTENERS: LISTENER_INTERNAL://kafka-broker-2:29092,LISTENER_HOST://localhost:_{PORT_COMMAND}
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: LISTENER_INTERNAL:PLAINTEXT,LISTENER_HOST:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: LISTENER_INTERNAL
KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'true'
healthcheck:
test:
[
'CMD',
'/opt/kafka/bin/kafka-topics.sh',
'--list',
'--bootstrap-server',
'kafka-broker-2:29092',
]
interval: 10s
timeout: 5s
retries: 5
kafka-broker-3:
image: wurstmeister/kafka:latest
restart: always
depends_on:
- zookeeper-kafka
ports:
- '9094:9092'
volumes:
# It's the only way to deal with Kafka non-static exposed ports to host
# See: https://github.com/wurstmeister/kafka-docker/blob/master/start-kafka.sh#L65-L76
- /var/run/docker.sock:/var/run/docker.sock
environment:
KAFKA_BROKER_ID: 3
KAFKA_ZOOKEEPER_CONNECT: 'zookeeper-kafka:2181'
PORT_COMMAND: 'docker port $$(hostname) 9092/tcp | cut -d: -f2'
KAFKA_LISTENERS: 'LISTENER_INTERNAL://kafka-broker-3:29092,LISTENER_HOST://:9092'
KAFKA_JMX_OPTS: "-Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=kafka-broker-3 -Dcom.sun.management.jmxremote.rmi.port=1099"
JMX_PORT: 1099
KAFKA_ADVERTISED_LISTENERS: LISTENER_INTERNAL://kafka-broker-3:29092,LISTENER_HOST://localhost:_{PORT_COMMAND}
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: LISTENER_INTERNAL:PLAINTEXT,LISTENER_HOST:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: LISTENER_INTERNAL
KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'true'
healthcheck:
test:
[
'CMD',
'/opt/kafka/bin/kafka-topics.sh',
'--list',
'--bootstrap-server',
'kafka-broker-3:29092',
]
interval: 10s
timeout: 5s
retries: 5
kafka-ui:
container_name: kafka-ui
image: provectuslabs/kafka-ui:latest
ports:
- "8080:8080"
depends_on:
- zookeeper-kafka
- kafka-broker-1
- kafka-broker-2
- kafka-broker-3
environment:
KAFKA_CLUSTERS_0_NAME: local
KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka-broker-1:29092, kafka-broker-2:29092, kafka-broker-3:29092
KAFKA_CLUSTERS_0_ZOOKEEPER: zookeeper-kafka:2181
KAFKA_CLUSTERS_0_JMXPORT: 1099