spotify / docker-kafka

Kafka (and Zookeeper) in Docker
Apache License 2.0
1.4k stars 643 forks source link

Fix: ADVERTISED_{HOST,PORT} params are ignored on container restart #99

Closed choopm closed 1 year ago

choopm commented 5 years ago

I noticed that if the container IP changes from container stop to container start (happens frequently if being used in a docker-compose'd environment), kafkas server.properties won't be updated due to a typo: # instead of ^ in sed expressions

As a result (if using IP adresses as ADVERTISED_HOST), clients trying to connect will be disconnected and reconnecting to the wrong IP. For a java based client it looks like this:

WARN  [org.apache.kafka.clients.NetworkClient] (KafkaJCAClient) Error while fetching metadata with correlation id 15326 : {mytopic=LEADER_NOT_AVAILABLE}
WARN  [org.apache.kafka.clients.NetworkClient] (KafkaJCAClient) Error while fetching metadata with correlation id 15327 : {mytopic=LEADER_NOT_AVAILABLE}
WARN  [org.apache.kafka.clients.NetworkClient] (KafkaJCAClient) Error while fetching metadata with correlation id 15328 : {mytopic=LEADER_NOT_AVAILABLE}
...

So if you're using IP adresses in ADVERTISED_HOST like me, containers need to be recreated all the time unless this PR gets merged.