from kafka import KafkaProducer
import time
producer = KafkaProducer(bootstrap_servers=['localhost:9092'])
i = 0
while 1:
# "kafkaesque" is the name of our topic
producer.send("stupid", str(i))
i += 1
time.sleep(1)

Can someone point out, how to solve this. I have some idea, as in the network port of the docker is not able to interact with the network port of the host, but i have tried EXPOSE and -p each of which is not helping me.