-
Notifications
You must be signed in to change notification settings - Fork 1
/
docker-compose.yml
46 lines (44 loc) · 1.86 KB
/
docker-compose.yml
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
# Based on https://github.com/confluentinc/cp-docker-images/blob/master/examples/cp-all-in-one/docker-compose.yml
version: '3'
services:
zookeeper:
build:
context: .
dockerfile: kafka.Dockerfile
command: >
bash -c "/init.sh
&& confluent-community/bin/zookeeper-server-start confluent-community/etc/kafka/zookeeper.properties"
hostname: zookeeper
container_name: zookeeper
ports:
- 2181:2181
environment:
CONFIG_PATH: 'confluent-community/etc/kafka/zookeeper.properties'
ZOOKEEPER_CLIENT_PORT: 2181
kafka:
build:
context: .
dockerfile: kafka.Dockerfile
hostname: kafka
container_name: kafka
command: >
bash -c "/wait-for-it.sh zookeeper:2181 -t 60
&& /init.sh
&& confluent-community/bin/kafka-server-start confluent-community/etc/kafka/server.properties"
depends_on:
- zookeeper
ports:
- 9092:9092
- 9093:9093
environment:
CONFIG_PATH: 'confluent-community/etc/kafka/server.properties'
KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'
# We need zookeeper to advertise two different urls since the broker has to be reachable
# from two different environments (once from inside the docker network and once from the host)
# However it is neither possible to advertise two listeners but only configure one via KAFKA_LISTENERS
# nor is it possible to advertise two listeners with the same protocol but different ports and hostnames since
# they are still considered to have the same name.
# We can do nothing about the former case but we can trick kafka with a custom protocol in the latter case.
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: 'LOCAL:PLAINTEXT,PLAINTEXT:PLAINTEXT'
KAFKA_LISTENERS: 'LOCAL://:9092,PLAINTEXT://kafka:9093'
KAFKA_ADVERTISED_LISTENERS: 'LOCAL://localhost:9092,PLAINTEXT://kafka:9093'