Skip to content

Instantly share code, notes, and snippets.

@sasaken555
Created January 18, 2020 08:02
Show Gist options
  • Save sasaken555/28c4a1e334723e1d5ff8156d728baf56 to your computer and use it in GitHub Desktop.
Save sasaken555/28c4a1e334723e1d5ff8156d728baf56 to your computer and use it in GitHub Desktop.
Docker Compose YAML for creating Apache Kafka cluster w/ Confluent Platform Docker containers.
version: "3"
services:
zookeeper:
image: confluentinc/cp-zookeeper:5.4.0
hostname: zookeeper
container_name: zookeeper
ports:
- "32181:32181"
environment:
ZOOKEEPER_CLIENT_PORT: 32181
ZOOKEEPER_TICK_TIME: 2000
broker:
image: confluentinc/cp-kafka:5.4.0
hostname: broker
container_name: broker
depends_on:
- zookeeper
ports:
- "29092:29092"
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: "zookeeper:32181"
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://broker:9092,PLAINTEXT_HOST://localhost:29092
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
cli:
image: confluentinc/cp-kafka:5.4.0
hostname: cli
container_name: cli
depends_on:
- broker
entrypoint: /bin/sh
tty: true
@sasaken555
Copy link
Author

If you want to connect brokers from local machine, use tcp://localhost:29092.
If from cli container, use tcp://broker:9092.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment