On my repository I have run docker-compose up -d
on the root directory and I am checking the myapp container logs. The producer and consumer Python files are unable to connect to the Kafka broker, prompting the error:
Failed to resolve 'broker:29092'
In my docker-compose.yml file, you'll notice that I have the following line on the Kafka container (I'm using the confluent Kafka image https://hub.docker.com/r/confluentinc/cp-kafka/).
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://broker:29092,PLAINTEXT_HOST://localhost:9092
From my limited understanding of networks, this line tells that the external host must connect to localhost:9092, whereas internal hosts should connect to broker:29092.
Since I'm trying to connect from the inside, my producer.py file uses broker:29082 as the bootstrap.server, same for the consumer.py. However, for some unknown reason, the connection is not being established. How can I overcome this problem?
p=Producer({'bootstrap.servers':'broker:29092'})