Reputation: 1484
I have built a docker image for kafka(wurstmeister/kafka-docker). Inside docker container I am able to create topic, produce messages and consume messages using the builtin shell scripts. Now I am using code hosted at https://github.com/mapr-demos/kafka-sample-programs to connect to kafka broker from my host machine. After building and running the program nothing happens and program stucks. I guess producer.send is not able to connect to kafka broker. Any help is appreciated
Upvotes: 1
Views: 1585
Reputation: 11
I am using ches/kafka docker image. Have a look at the explanation of KAFKA_ADVERTISED_HOST_NAME.
Upvotes: 1
Reputation: 1069
You can see that both the consumer.properties
and the producer.properties
files in that project specify bootstrap.servers=localhost:9092
.
Since you cannot connect to the dockerized kafka service using localhost:9092
, you might try finding the IP address of the docker container, by using, for example, docker inspect kafka | grep IPA
(assuming that the name of your container is kafka
). Then replace localhost
with that IP address in those two properties files.
Upvotes: 1