I have a docker-compose.yml
file:
version: '2'
services:
zookeeper:
image: confluentinc/cp-zookeeper:latest
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
ports:
- 2181:2181
kafka:
image: confluentinc/cp-kafka:latest
depends_on:
- zookeeper
ports:
- 9092:9092
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://broker:29092,PLAINTEXT_HOST://localhost:9092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_HOST:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: PLAINTEXT
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
The containers (based on these 2 images from this file) works well, but I can’t connect to localhost:9092
(using offset explorer for kafka)
Could you help me understand what is wrong in this docker-compose.yml
file?
2
Answers
You are missing a line like this
https://www.confluent.io/blog/kafka-listeners-explained/
Setting up the Bootstrap servers like this under Advanced tabs did the trick for me: 1.
In the properties tab, set the Zookeeper Host and port to "localhost" and "2181" .