holografix
holografix

Reputation: 610

Kafka on Docker cannot connect from other container

Hi I’m using Spotify/Kafka and am running it with

docker run —name ka -p 9092:9092 -p 2181:2181 —env ADVERTISED_HOST=localhost —env ADVERTISED_PORT 2181 —net mynet spotify/kafka

I make sure I run my second container using the same net and I can ping the Kafka container using ka.mynet

Also in this second container I downloaded kafka and it’s shell scripts and I’m able to do a

./kafka-topics.sh —zookeeper ka.mynet —list and see the “Test” topic

Now any attempt to produce or consume spits out errors. Producer complains about something to do with not finding a leader.

Other Googling has led me to believe it has something to do with the advertised host.

Upvotes: 1

Views: 1136

Answers (1)

holografix
holografix

Reputation: 610

Ok it seems like the only way to get this to work is to assign my machine's current IP address as the ADVERTISED_HOST env variable.

So if my machine's IP is 192.168.1.11 then:

docker run —name ka -p 9092:9092 -p 2181:2181 —env ADVERTISED_HOST=192.168.1.11 —env ADVERTISED_PORT=9092 —net mynet spotify/kafka

Upvotes: 1

Related Questions