Failed to resolve 'kafka:9092': Name or service not known - docker / php-rdkafka Failed to resolve 'kafka:9092': Name or service not known - docker / php-rdkafka docker docker

Failed to resolve 'kafka:9092': Name or service not known - docker / php-rdkafka


The brokers will advertise themselve using advertised.listeners (which seems to be abstracted with KAFKA_ADVERTISED_HOST_NAME in that docker image) and the clients will consequently try to connect to these advertised hosts and ports.

You will thus need to make sure the client can resolve and reach this advertised hostnames, e.g. by adding "kafka" to /etc/hosts on the client host.


if containers' host IP is 192.168.1.110,could set it in docker container env:

KAFKA_ADVERTISED_LISTENERS: "PLAINTEXT://192.168.1.110:{{ kafka_port }}"


I have added the following in the hosts file of the OS (on windows - C:\Windows\System32\drivers\Etc\hosts & on linux - vi /etc/hosts): kafkaThen could see the kafka messages coming through from that machine to my machine locally.