Docker Community Forums

Share and learn in the Docker community.

Not Able To Access Kafka Services Outside Docker Image

(Sunilmanika) #1

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 and scripts provided by Kafka. The required ports are exposed too.

PORTS>2182/tcp, 22/tcp,>9093/tcp

Below are the configurations done in of Kafka,


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.

(Sunilmanika) #2

2017-12-17 21:30:51 DEBUG NetworkClient:189 - [Producer clientId=KafkaExampleProducer] Sending metadata request (type=MetadataRequest, to node (id: -1 rack: null)
2017-12-17 21:30:51 DEBUG NetworkClient:195 - [Producer clientId=KafkaExampleProducer] Using older server API v1 to send METADATA {topics=[]} with correlation id 2 to node -1
2017-12-17 21:30:52 DEBUG Metadata:270 - Updated cluster metadata version 2 to Cluster(id = null, nodes = [ (id: 0 rack: null)], partitions = [Partition(topic =, partition = 0, leader = 0, replicas = [0], isr = [0], offlineReplicas = [])])
2017-12-17 21:30:52 DEBUG NetworkClient:183 - [Producer clientId=KafkaExampleProducer] Initiating connection to node 0