0

I am writing in a weird error when trying to connect to my Kafka. It is running within a docker container. Under docker ps:

1f95e13436a7 bitnami/kafka:latest "/opt/bitnami/script…" 12 minutes ago Up 5 minutes 0.0.0.0:9092->9092/tcp, :::9092->9092/tcp kafka

I thought I could then do this (from my local host):

kafka-topics.sh --list --bootstrap-server localhost:9092

But this command gives me the following error:

[2022-01-18 09:37:21,034] WARN [AdminClient clientId=adminclient-1] Error connecting   
to node 1f95e13436a7:9092 (id: 1001 rack: null) 
(org.apache.kafka.clients.NetworkClient)
java.net.UnknownHostException: 1f95e13436a7
at java.base/java.net.InetAddress$CachedAddresses.get(InetAddress.java:797)
at java.base/java.net.InetAddress.getAllByName0(InetAddress.java:1509)
at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1368)
at java.base/java.net.InetAddress.getAllByName(InetAddress.java:1302)
at org.apache.kafka.clients.DefaultHostResolver.resolve(DefaultHostResolver.java:27)

That unknown host happens to be the Kafka docker container ID I am asking it connect to localhost and not the docker container ID as the host. Why is it complaining the docker container ID as unknown host?

thanks

Vince Yau
  • 515
  • 1
  • 5
  • 16
  • Does this help? https://stackoverflow.com/a/42670735/2777988 – Rakesh Gupta Jan 18 '22 at 21:08
  • You need to set the variable for advertised listeners in your docker container https://www.confluent.io/blog/kafka-listeners-explained/ . Kafka is very, very complicated technology. If you want to learn it, I would suggest to read a few books and plenty of blog posts while trying it. – Augusto Jan 18 '22 at 21:10
  • Did you start the container on the host a network? – Margach Chris Jan 18 '22 at 21:13
  • Read the README of the bitnami containers. It tells you exactly what properties to add to make external connections from the host. To answer your question about the container ID, that's the default advertised listener for Kafka - the hostname of the server (in this case, the container ID) – OneCricketeer Jan 19 '22 at 04:31
  • thanks all, will explore these options. It does look like I have to define these listeners – Vince Yau Jan 19 '22 at 05:06

0 Answers0