Adding this since it may help others. A Common problem can be a misconfiguration of advertised.host.name
. With Docker using docker-compose setting the name of the service inside KAFKA_ADVERTISED_HOST_NAME
wont work unless you set the hostname as well. docker-compose.yml
example:
kafka:
image: wurstmeister/kafka
ports:
- "9092:9092"
hostname: kafka
environment:
KAFKA_ADVERTISED_HOST_NAME: kafka
KAFKA_CREATE_TOPICS: "test:1:1"
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
volumes:
- /var/run/docker.sock:/var/run/docker.sock
The above without hostname: kafka
can issue a LEADER_NOT_AVAILABLE
when trying to connect.
You can find an example of a working docker-compose
configuration here