Docker Compose - Kafka 사용하기

목차

Zookeeper 설정

version: "3"
services:
zookeeper:
container_name: local-zookeeper
image: wurstmeister/zookeeper
ports:
- 2181:2181

Kafka 설정

version: "3"
services:
zookeeper:
container_name: local-zookeeper
image: wurstmeister/zookeeper
ports:
- 2181:2181
kafka:
container_name: local-kafka
image: wurstmeister/kafka
depends_on:
- zookeeper
ports:
- 9092:9092
environment:
KAFKA_ADVERTISED_HOST_NAME: 127.0.0.1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
volumes:
- /var/run/docker.sock:/var/run/docker.sock

전체 소스 코드

version: "3"
services:
zookeeper:
container_name: local-zookeeper
image: wurstmeister/zookeeper
ports:
- 2181:2181
kafka:
container_name: local-kafka
image: wurstmeister/kafka
depends_on:
- zookeeper
ports:
- 9092:9092
environment:
KAFKA_ADVERTISED_HOST_NAME: 127.0.0.1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
volumes:
- /var/run/docker.sock:/var/run/docker.sock
Share