Cannot send a message to Kafka from a service running in docker

I have a service running in a docker container on port 5000 that is used to create a kafka-related message ending in a docker container.

I configured my manufacturing client with the following properties: -

bootstrap.servers=localhost:9093

And I started with my team: -

docker run -d -p 127.0.0.1:5000:5000 <contained id>

I also made the following configuration for advertising the host and port kafka

advertised.host.name=localhost
advertised.port=9093

Despite all the configuration, when I try to create a kafka theme, I get below the error: -

org.apache.kafka.common.errors.TimeoutException: Failed to update metadata after 60000 ms.

Can anyone indicate what the problem is?

+4
source share
1 answer

In real life, advertised.host.nameit should never be localhost.

Docker , localhost, , -.

, advertised.host.name bootstrap.servers IP-, ifconfig docker0 ( , docker0 , ).

--net=host, , .

+3

Source: https://habr.com/ru/post/1649878/


All Articles