I have created a kafka docker image on centos. Here, I am running both Zookeeper and Kafka server on the same image.
I see that the services are up and running inside the docker container. I have tested kafka through kafka-console-producer.sh and kafka-console-consumer.sh scripts provided by Kafka. The required ports are exposed too.
PORTS
0.0.0.0:2182->2182/tcp, 22/tcp, 0.0.0.0:9093->9093/tcp
Below are the configurations done in server.properties of Kafka,
listeners=PLAINTEXT://0.0.0.0:9093
zookeeper.connect=localhost:2182
I have created a topic inside the docker container.
I am able to access the Kafka services through an external machine (in the same network) using telnet command on the host where my docker image is running.
telnet 9093
Trying …
Connected to .
Escape character is ‘^]’.
telnet 2182
Trying …
Connected to .
Escape character is ‘^]’.
However, writing data to Kafka topic fails with TimeoutExceptions.
2017-12-17 21:31:47 INFO KafkaProducer:341 - [Producer clientId=KafkaExampleProducer] Closing the Kafka producer with timeoutMillis = 9223372036854775807 ms.
2017-12-17 21:31:47 DEBUG Sender:177 - [Producer clientId=KafkaExampleProducer] Beginning shutdown of Kafka producer I/O thread, sending remaining records.
Let me know on how to write data to Kafka topic.