Unable to connect Schema Registry to existing kafka setup [duplicate] - docker

I'm running ksqldb-server from a docker-compor found here https://ksqldb.io/quickstart.html#quickstart-content
My kafka bootstrap server is running on the same VM in standard alone mode.
I can see the messages in one topic with a console consumer:
sudo kafka-avro-console-consumer --from-beginning --bootstrap-server localhost:9092 --topic source-air-input --property print.key=true --max-messages 2
Unfortunatly running ksql from docker gives me this error.
ksqldb-server | [2021-07-15 23:12:58,772] ERROR Failed to start KSQL (io.confluent.ksql.rest.server.KsqlServerMain:66)
ksqldb-server | java.lang.RuntimeException: Failed to get Kafka cluster information
ksqldb-server | at io.confluent.ksql.services.KafkaClusterUtil.getKafkaClusterId(KafkaClusterUtil.java:107)
ksqldb-server | at io.confluent.ksql.rest.server.KsqlRestApplication.buildApplication(KsqlRestApplication.java:624)
ksqldb-server | at io.confluent.ksql.rest.server.KsqlServerMain.createExecutable(KsqlServerMain.java:152)
ksqldb-server | at io.confluent.ksql.rest.server.KsqlServerMain.main(KsqlServerMain.java:59)
ksqldb-server | Caused by: java.util.concurrent.TimeoutException
ksqldb-server | at org.apache.kafka.common.internals.KafkaFutureImpl$SingleWaiter.await(KafkaFutureImpl.java:108)
ksqldb-server | at org.apache.kafka.common.internals.KafkaFutureImpl.get(KafkaFutureImpl.java:272)
ksqldb-server | at io.confluent.ksql.services.KafkaClusterUtil.getKafkaClusterId(KafkaClusterUtil.java:105)
My docker-compose.yml is the following.
---
version: '3.9'
services:
ksqldb-server:
image: confluentinc/ksqldb-server:0.18.0
hostname: ksqldb-server
container_name: ksqldb-server
extra_hosts:
- "host.docker.internal:host-gateway"
ports:
- "8088:8088"
environment:
KSQL_LISTENERS: http://0.0.0.0:8088
KSQL_BOOTSTRAP_SERVERS: host.docker.internal:9092
KSQL_KSQL_LOGGING_PROCESSING_STREAM_AUTO_CREATE: "true"
KSQL_KSQL_LOGGING_PROCESSING_TOPIC_AUTO_CREATE: "true"
ksqldb-cli:
image: confluentinc/ksqldb-cli:0.18.0
container_name: ksqldb-cli
depends_on:
- ksqldb-server
entrypoint: /bin/sh
tty: true
I tried many possible configurations for the address without success.
What might be wrong?
I tried the suggestions from this question From inside of a Docker container, how do I connect to the localhost of the machine? without success.

Modify Kafka's server.properties
listener.security.protocol.map=PLAINTEXT_DOCKER:PLAINTEXT,PLAINTEXT_LOCAL:PLAINTEXT
listeners=PLAINTEXT_DOCKER://:29092,PLAINTEXT_LOCAL://localhost:9092
advertised.listeners=PLAINTEXT_DOCKER://host.docker.internal:29092,PLAINTEXT_LOCAL://localhost:9092
inter.broker.listener.name=PLAINTEXT_LOCAL
Update your Compose like so to point at the host rather than itself
version: '3.9'
services:
# TODO: add schema-registry
# environment:
# SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS: host.docker.internal:29092
# extra_hosts:
# - "host.docker.internal:host-gateway"
# or any other Kafka client
ksqldb-server:
image: confluentinc/ksqldb-server:0.18.0
hostname: ksqldb-server
container_name: ksqldb-server
ports:
- "8088:8088"
extra_hosts:
- "host.docker.internal:host-gateway"
environment:
KSQL_BOOTSTRAP_SERVERS: host.docker.internal:29092
...
(Tested on Mac), Getting /info endpoint of KSQL
http :8088/info
HTTP/1.1 200 OK
content-length: 133
content-type: application/json
{
"KsqlServerInfo": {
"kafkaClusterId": "ZH2-h1W_SaivCW0qa8DQGA",
"ksqlServiceId": "default_",
"serverStatus": "RUNNING",
"version": "0.18.0"
}
}
Replace all host.docker.internal above with the external hostname/IP of the machine, if Kafka is a remote server

Related

UI for Apache Kafka does not Connect [duplicate]

I'm running ksqldb-server from a docker-compor found here https://ksqldb.io/quickstart.html#quickstart-content
My kafka bootstrap server is running on the same VM in standard alone mode.
I can see the messages in one topic with a console consumer:
sudo kafka-avro-console-consumer --from-beginning --bootstrap-server localhost:9092 --topic source-air-input --property print.key=true --max-messages 2
Unfortunatly running ksql from docker gives me this error.
ksqldb-server | [2021-07-15 23:12:58,772] ERROR Failed to start KSQL (io.confluent.ksql.rest.server.KsqlServerMain:66)
ksqldb-server | java.lang.RuntimeException: Failed to get Kafka cluster information
ksqldb-server | at io.confluent.ksql.services.KafkaClusterUtil.getKafkaClusterId(KafkaClusterUtil.java:107)
ksqldb-server | at io.confluent.ksql.rest.server.KsqlRestApplication.buildApplication(KsqlRestApplication.java:624)
ksqldb-server | at io.confluent.ksql.rest.server.KsqlServerMain.createExecutable(KsqlServerMain.java:152)
ksqldb-server | at io.confluent.ksql.rest.server.KsqlServerMain.main(KsqlServerMain.java:59)
ksqldb-server | Caused by: java.util.concurrent.TimeoutException
ksqldb-server | at org.apache.kafka.common.internals.KafkaFutureImpl$SingleWaiter.await(KafkaFutureImpl.java:108)
ksqldb-server | at org.apache.kafka.common.internals.KafkaFutureImpl.get(KafkaFutureImpl.java:272)
ksqldb-server | at io.confluent.ksql.services.KafkaClusterUtil.getKafkaClusterId(KafkaClusterUtil.java:105)
My docker-compose.yml is the following.
---
version: '3.9'
services:
ksqldb-server:
image: confluentinc/ksqldb-server:0.18.0
hostname: ksqldb-server
container_name: ksqldb-server
extra_hosts:
- "host.docker.internal:host-gateway"
ports:
- "8088:8088"
environment:
KSQL_LISTENERS: http://0.0.0.0:8088
KSQL_BOOTSTRAP_SERVERS: host.docker.internal:9092
KSQL_KSQL_LOGGING_PROCESSING_STREAM_AUTO_CREATE: "true"
KSQL_KSQL_LOGGING_PROCESSING_TOPIC_AUTO_CREATE: "true"
ksqldb-cli:
image: confluentinc/ksqldb-cli:0.18.0
container_name: ksqldb-cli
depends_on:
- ksqldb-server
entrypoint: /bin/sh
tty: true
I tried many possible configurations for the address without success.
What might be wrong?
I tried the suggestions from this question From inside of a Docker container, how do I connect to the localhost of the machine? without success.
Modify Kafka's server.properties
listener.security.protocol.map=PLAINTEXT_DOCKER:PLAINTEXT,PLAINTEXT_LOCAL:PLAINTEXT
listeners=PLAINTEXT_DOCKER://:29092,PLAINTEXT_LOCAL://localhost:9092
advertised.listeners=PLAINTEXT_DOCKER://host.docker.internal:29092,PLAINTEXT_LOCAL://localhost:9092
inter.broker.listener.name=PLAINTEXT_LOCAL
Update your Compose like so to point at the host rather than itself
version: '3.9'
services:
# TODO: add schema-registry
# environment:
# SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS: host.docker.internal:29092
# extra_hosts:
# - "host.docker.internal:host-gateway"
# or any other Kafka client
ksqldb-server:
image: confluentinc/ksqldb-server:0.18.0
hostname: ksqldb-server
container_name: ksqldb-server
ports:
- "8088:8088"
extra_hosts:
- "host.docker.internal:host-gateway"
environment:
KSQL_BOOTSTRAP_SERVERS: host.docker.internal:29092
...
(Tested on Mac), Getting /info endpoint of KSQL
http :8088/info
HTTP/1.1 200 OK
content-length: 133
content-type: application/json
{
"KsqlServerInfo": {
"kafkaClusterId": "ZH2-h1W_SaivCW0qa8DQGA",
"ksqlServiceId": "default_",
"serverStatus": "RUNNING",
"version": "0.18.0"
}
}
Replace all host.docker.internal above with the external hostname/IP of the machine, if Kafka is a remote server

Docker compose zookeeper java.net.NoRouteToHostException: No route to host

I have a local application with kafka and zookeeper but when i run docker compose up in my arch linux desktop kafka show this error:
container log:
kafka_1 | java.net.NoRouteToHostException: No route to host
kafka_1 | at java.base/sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
kafka_1 | at java.base/sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:777)
kafka_1 | at org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:344)
kafka_1 | at org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1290)
kafka_1 | [main-SendThread(zookeeper:2181)] INFO org.apache.zookeeper.ClientCnxn - Opening socket connection to server zookeeper/172.18.0.2:2181.
kafka_1 | [main-SendThread(zookeeper:2181)] INFO org.apache.zookeeper.ClientCnxn - SASL config status: Will not attempt to authenticate using SASL (unknown error)
kafka_1 | [main-SendThread(zookeeper:2181)] WARN org.apache.zookeeper.ClientCnxn - Session 0x0 for sever zookeeper/172.18.0.2:2181, Closing socket connection. Attempting reconnect except it is a SessionExpiredException.
docker compose file:
version: '3'
services:
zookeeper:
image: confluentinc/cp-zookeeper:latest
restart: unless-stopped
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ports:
- '2181:2181'
networks:
- domper-network
kafka:
image: confluentinc/cp-kafka:latest
restart: unless-stopped
depends_on:
- zookeeper
ports:
- '9092:9092'
- '9094:9094'
environment:
KAFKA_BROKER_ID: 1
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_INTER_BROKER_LISTENER_NAME: INTERNAL
KAFKA_LISTENERS: INTERNAL://:9092,OUTSIDE://:9094
KAFKA_ADVERTISED_LISTENERS: INTERNAL://kafka:9092,OUTSIDE://host.docker.internal:9094
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INTERNAL:PLAINTEXT,OUTSIDE:PLAINTEXT
extra_hosts:
- 'host.docker.internal:172.17.0.1' #gateway do docker
networks:
- domper-network
postgres:
image: postgres
restart: unless-stopped
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: Admin#2021!
POSTGRES_DB: domper
POSTGRES_HOST_AUTH_METHOD: password
ports:
- 5432:5432
volumes:
- postgres-domper-data:/var/lib/postgresql/data
networks:
- domper-network
pgadmin:
image: dpage/pgadmin4
restart: unless-stopped
environment:
PGADMIN_DEFAULT_EMAIL: 'admin#admin.com.br'
PGADMIN_DEFAULT_PASSWORD: 'Admin#2021!'
ports:
- 16543:80
depends_on:
- postgres
networks:
- domper-network
api:
build: ./
restart: 'no'
command: bash -c "npm i && npm run migration:run && npm run seed:run && npm run start:dev"
ports:
- 8888:8888
env_file:
- dev.env
volumes:
- ./:/var/www/api
- /var/www/api/node_modules/
depends_on:
- postgres
- kafka
networks:
- domper-network
# healthcheck:
# test: ["CMD", "curl", "-f", "http://localhost:8888/healthcheck"]
# interval: 60s
# timeout: 5s
# retries: 5
notification-service:
build: ../repoDomperNotification/
restart: 'no'
command: npm run start
ports:
- 8889:8889
env_file:
- dev.env
volumes:
- ../repoDomperNotification/:/var/www/notification
- /var/www/notification/node_modules/
depends_on:
- kafka
networks:
- domper-network
healthcheck:
test: ['CMD', 'curl', '-f', 'http://localhost:8889/healthcheck']
interval: 60s
timeout: 5s
retries: 5
volumes:
postgres-domper-data:
driver: local
networks:
domper-network:
but in my windows desktop works and i don't know what this mean, I think it's some host configuration.
I've tried all the things I found on the internet and none of them worked.
log after #OneCricketeer (remove remove host.docker.internal and the extra_hosts) suggestion:
repodompercore-kafka-1 | ===> Running preflight checks ...
repodompercore-kafka-1 | ===> Check if /var/lib/kafka/data is writable ...
repodompercore-kafka-1 | ===> Check if Zookeeper is healthy ...
repodompercore-kafka-1 | SLF4J: Class path contains multiple SLF4J bindings.
repodompercore-kafka-1 | SLF4J: Found binding in [jar:file:/usr/share/java/cp-base-new/slf4j-log4j12-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class]
repodompercore-kafka-1 | SLF4J: Found binding in [jar:file:/usr/share/java/cp-base-new/slf4j-simple-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class]
repodompercore-kafka-1 | SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
repodompercore-kafka-1 | SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
repodompercore-kafka-1 | log4j:WARN No appenders could be found for logger (io.confluent.admin.utils.cli.ZookeeperReadyCommand).
repodompercore-kafka-1 | log4j:WARN Please initialize the log4j system properly.
repodompercore-kafka-1 | log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
repodompercore-kafka-1 exited with code 1

Connect to Kafka on host from Docker (ksqlDB)

I'm running ksqldb-server from a docker-compor found here https://ksqldb.io/quickstart.html#quickstart-content
My kafka bootstrap server is running on the same VM in standard alone mode.
I can see the messages in one topic with a console consumer:
sudo kafka-avro-console-consumer --from-beginning --bootstrap-server localhost:9092 --topic source-air-input --property print.key=true --max-messages 2
Unfortunatly running ksql from docker gives me this error.
ksqldb-server | [2021-07-15 23:12:58,772] ERROR Failed to start KSQL (io.confluent.ksql.rest.server.KsqlServerMain:66)
ksqldb-server | java.lang.RuntimeException: Failed to get Kafka cluster information
ksqldb-server | at io.confluent.ksql.services.KafkaClusterUtil.getKafkaClusterId(KafkaClusterUtil.java:107)
ksqldb-server | at io.confluent.ksql.rest.server.KsqlRestApplication.buildApplication(KsqlRestApplication.java:624)
ksqldb-server | at io.confluent.ksql.rest.server.KsqlServerMain.createExecutable(KsqlServerMain.java:152)
ksqldb-server | at io.confluent.ksql.rest.server.KsqlServerMain.main(KsqlServerMain.java:59)
ksqldb-server | Caused by: java.util.concurrent.TimeoutException
ksqldb-server | at org.apache.kafka.common.internals.KafkaFutureImpl$SingleWaiter.await(KafkaFutureImpl.java:108)
ksqldb-server | at org.apache.kafka.common.internals.KafkaFutureImpl.get(KafkaFutureImpl.java:272)
ksqldb-server | at io.confluent.ksql.services.KafkaClusterUtil.getKafkaClusterId(KafkaClusterUtil.java:105)
My docker-compose.yml is the following.
---
version: '3.9'
services:
ksqldb-server:
image: confluentinc/ksqldb-server:0.18.0
hostname: ksqldb-server
container_name: ksqldb-server
extra_hosts:
- "host.docker.internal:host-gateway"
ports:
- "8088:8088"
environment:
KSQL_LISTENERS: http://0.0.0.0:8088
KSQL_BOOTSTRAP_SERVERS: host.docker.internal:9092
KSQL_KSQL_LOGGING_PROCESSING_STREAM_AUTO_CREATE: "true"
KSQL_KSQL_LOGGING_PROCESSING_TOPIC_AUTO_CREATE: "true"
ksqldb-cli:
image: confluentinc/ksqldb-cli:0.18.0
container_name: ksqldb-cli
depends_on:
- ksqldb-server
entrypoint: /bin/sh
tty: true
I tried many possible configurations for the address without success.
What might be wrong?
I tried the suggestions from this question From inside of a Docker container, how do I connect to the localhost of the machine? without success.
Modify Kafka's server.properties
listener.security.protocol.map=PLAINTEXT_DOCKER:PLAINTEXT,PLAINTEXT_LOCAL:PLAINTEXT
listeners=PLAINTEXT_DOCKER://:29092,PLAINTEXT_LOCAL://localhost:9092
advertised.listeners=PLAINTEXT_DOCKER://host.docker.internal:29092,PLAINTEXT_LOCAL://localhost:9092
inter.broker.listener.name=PLAINTEXT_LOCAL
Update your Compose like so to point at the host rather than itself
version: '3.9'
services:
# TODO: add schema-registry
# environment:
# SCHEMA_REGISTRY_KAFKASTORE_BOOTSTRAP_SERVERS: host.docker.internal:29092
# extra_hosts:
# - "host.docker.internal:host-gateway"
# or any other Kafka client
ksqldb-server:
image: confluentinc/ksqldb-server:0.18.0
hostname: ksqldb-server
container_name: ksqldb-server
ports:
- "8088:8088"
extra_hosts:
- "host.docker.internal:host-gateway"
environment:
KSQL_BOOTSTRAP_SERVERS: host.docker.internal:29092
...
(Tested on Mac), Getting /info endpoint of KSQL
http :8088/info
HTTP/1.1 200 OK
content-length: 133
content-type: application/json
{
"KsqlServerInfo": {
"kafkaClusterId": "ZH2-h1W_SaivCW0qa8DQGA",
"ksqlServiceId": "default_",
"serverStatus": "RUNNING",
"version": "0.18.0"
}
}
Replace all host.docker.internal above with the external hostname/IP of the machine, if Kafka is a remote server

kafka docker stuck on configuration and not working on mac

I am trying to use kafka on docker. But when running the docker compose, kafka just stuck on configuring mode and not indicating that already running. I do listing for kafka topics but it's not working or not giving the response. Here's my docker-compose.yml:
version: '3'
services:
zookeeper:
image: wurstmeister/zookeeper
container_name: zookeeper
hostname: zookeeper
ports:
- 2181:2181
environment:
ZOO_MY_ID: 1
networks:
- kafka_net
kafka:
image: wurstmeister/kafka
container_name: kafka
ports:
- 9092:9092
expose:
- 9092
depends_on:
- zookeeper
environment:
KAFKA_ADVERTISED_HOST_NAME: localhost
KAFKA_ADVERTISED_PORT: 9092
KAFKA_LISTENERS: INSIDE://0.0.0.0:9092,OUTSIDE://0.0.0.0:9092
KAFKA_ADVERTISED_LISTENERS: INSIDE://kafka:9092,OUTSIDE://localhost:9092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: INSIDE
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_BROKER_ID: 1
restart: always
networks:
- kafka_net
networks:
kafka_net:
driver: "bridge"
Here's the zookeeper response on docker-compose log:
2021-04-19 01:07:56,385 [myid:] - INFO [main:Environment#100] - Server environment:user.dir=/opt/zookeeper-3.4.13
2021-04-19 01:07:56,393 [myid:] - INFO [main:ZooKeeperServer#836] - tickTime set to 2000
2021-04-19 01:07:56,394 [myid:] - INFO [main:ZooKeeperServer#845] - minSessionTimeout set to -1
2021-04-19 01:07:56,394 [myid:] - INFO [main:ZooKeeperServer#854] - maxSessionTimeout set to -1
2021-04-19 01:07:56,418 [myid:] - INFO [main:ServerCnxnFactory#117] - Using org.apache.zookeeper.server.NIOServerCnxnFactory as server connection factory
2021-04-19 01:07:56,430 [myid:] - INFO [main:NIOServerCnxnFactory#89] - binding to port 0.0.0.0/0.0.0.0:2181
Here's the only kafka response on docker-compose log:
kafka | [Configuring] 'log.dirs' in '/opt/kafka/config/server.properties'
kafka | [Configuring] 'zookeeper.connect' in '/opt/kafka/config/server.properties'
kafka | [Configuring] 'listeners' in '/opt/kafka/config/server.properties'
kafka | Excluding KAFKA_VERSION from broker config
kafka | [Configuring] 'broker.id' in '/opt/kafka/config/server.properties'
kafka | [Configuring] 'listener.security.protocol.map' in '/opt/kafka/config/server.properties'
kafka | [Configuring] 'advertised.listeners' in '/opt/kafka/config/server.properties'
kafka | [Configuring] 'port' in '/opt/kafka/config/server.properties'
kafka | [Configuring] 'advertised.host.name' in '/opt/kafka/config/server.properties'
kafka | Excluding KAFKA_HOME from broker config
kafka | [Configuring] 'advertised.port' in '/opt/kafka/config/server.properties'
kafka | [Configuring] 'inter.broker.listener.name' in '/opt/kafka/config/server.properties'
When running this command, it's not giving a response:
docker exec -it kafka /bin/sh
/ # cd /opt/kafka_2.13-2.7.0
/opt/kafka_2.13-2.7.0 # bin/kafka-topics.sh --list --zookeeper zookeeper:2181
what should i do on this? i still trying to make it run. I already try with kafka native (without docker) and it run perfectly the i can create a topic
Try to use another image of kafka, to example - bitnami. I had the same problem as you on Apple M1 Big Shur, and i used bitnami and it's working!! this is my docker-compose.yml:
version: "2"
services:
zookeeper:
image: docker.io/bitnami/zookeeper:3
ports:
- "2181:2181"
volumes:
- "zookeeper_data:/bitnami"
environment:
- ALLOW_ANONYMOUS_LOGIN=yes
kafka:
image: docker.io/bitnami/kafka:2
ports:
- "9092:9092"
volumes:
- "kafka_data:/bitnami"
environment:
- KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181
- ALLOW_PLAINTEXT_LISTENER=yes
- KAFKA_LISTENERS=PLAINTEXT://:9092
- KAFKA_ADVERTISED_LISTENERS=PLAINTEXT://127.0.0.1:9092
depends_on:
- zookeeper
volumes:
zookeeper_data:
driver: local
kafka_data:
driver: local
Seems like you missed an important part from your docker-compose log. I ran your docker-compose file on my local and would like to highlight this part from the logs.
kafka | [2021-04-19 09:20:19,209] INFO Setting -D jdk.tls.rejectClientInitiatedRenegotiation=true to disable client-initiated TLS renegotiation (org.apache.zookeeper.common.X509Util)
kafka | [2021-04-19 09:20:19,253] ERROR Exiting Kafka due to fatal exception (kafka.Kafka$)
kafka | java.lang.IllegalArgumentException: requirement failed: Each listener must have a different port, listeners: INSIDE://0.0.0.0:9092,OUTSIDE://0.0.0.0:9092
kafka | at kafka.utils.CoreUtils$.validate$1(CoreUtils.scala:265)
kafka | at kafka.utils.CoreUtils$.listenerListToEndPoints(CoreUtils.scala:276)
kafka | at kafka.server.KafkaConfig.$anonfun$listeners$1(KafkaConfig.scala:1680)
kafka | at kafka.server.KafkaConfig.listeners(KafkaConfig.scala:1679)
kafka | at kafka.server.KafkaConfig.validateValues(KafkaConfig.scala:1779)
kafka | at kafka.server.KafkaConfig.<init>(KafkaConfig.scala:1756)
kafka | at kafka.server.KafkaConfig.<init>(KafkaConfig.scala:1312)
kafka | at kafka.server.KafkaServerStartable$.fromProps(KafkaServerStartable.scala:34)
kafka | at kafka.Kafka$.main(Kafka.scala:68)
kafka | at kafka.Kafka.main(Kafka.scala)
kafka exited with code 1
So you were using the same port for accessing Kafka from inside and outside the docker network. I changed the below setting (the INSIDE port) and it worked for me. I was able to create and list topics. I was also able to produce and consume simple messages from the kafka container.
KAFKA_LISTENERS: INSIDE://0.0.0.0:29092,OUTSIDE://0.0.0.0:9092
KAFKA_ADVERTISED_LISTENERS: INSIDE://kafka:29092,OUTSIDE://localhost:9092
This is some of the testing I did from the kafka container
docker exec -it kafka bash
bash-4.4# cd /opt/kafka_2.13-2.7.0/
bash-4.4# bin/kafka-topics.sh --create --topic test-topic --partitions 16 --replication-factor 1 --zookeeper zookeeper:2181
Created topic test-topic.
bash-4.4# bin/kafka-topics.sh --list --zookeeper zookeeper:2181
test-topic
This is an excellent post that I would like to refer you. Please let me know if this works for you or not.

Error connecting to local Bitnami Docker Kafka from Spring Boot application

Spring Boot (version 2.2) application with Spring Kafka (version 2.4) can't establish a connection with Bitnami Docker Kafka (version 2) executed from the official docker-compose.yml
version: '2'
services:
zookeeper:
image: 'bitnami/zookeeper:3'
ports:
- '2181:2181'
volumes:
- 'zookeeper_data:/bitnami'
environment:
- ALLOW_ANONYMOUS_LOGIN=yes
kafka:
image: 'bitnami/kafka:2'
ports:
- '9092:9092'
volumes:
- 'kafka_data:/bitnami'
environment:
- KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181
- ALLOW_PLAINTEXT_LISTENER=yes
depends_on:
- zookeeper
volumes:
zookeeper_data:
driver: local
kafka_data:
driver: local
Spring application keeps producing the following warning:
[kafka-admin-client-thread | adminclient-1] WARN o.apache.kafka.clients.NetworkClient.initiateConnect - [AdminClient clientId=adminclient-1] Error connecting to node 2228a9a3b8c5:9092 (id: 1001 rack: null) java.net.UnknownHostException: 2228a9a3b8c5
or
[kafka-admin-client-thread | adminclient-1] WARN o.apache.kafka.clients.NetworkClient.processDisconnection - [AdminClient clientId=adminclient-1] Connection to node -1 (localhost/127.0.0.1:9092) could not be established. Broker may not be available.
To establish connection with Bitnami Docker Kafka running on `localhost, add the following environment variables:
KAFKA_CFG_LISTENERS=PLAINTEXT://:9092
KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092
docker-compose.yml kafka service:
kafka:
image: 'bitnami/kafka:2'
ports:
- '9092:9092'
volumes:
- 'kafka_data:/bitnami'
environment:
- KAFKA_CFG_ZOOKEEPER_CONNECT=zookeeper:2181
- ALLOW_PLAINTEXT_LISTENER=yes
- KAFKA_CFG_LISTENERS=PLAINTEXT://:9092
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://localhost:9092

Resources