I am trying to get php connecting to kafka all within a docker container.
kafka php lib - https://github.com/arnaud-lb/php-rdkafka/
kafk
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.