title: Kafka broker not accessible in docker compose
body: <p>I have created a docker compose file where my application wants to use kafka.</p>
  <p>docker-compose.yaml is:</p>
  <pre><code>
  version: '3.7'
  
  services:
    api:
      depends_on:
        - kafka
      restart: on-failure
      build:
        context: .
        dockerfile: Dockerfile
      ports:
        - 8080:8080
  
    zookeeper:
      image: wurstmeister/zookeeper
      ports:
        - &quot;2181:2181&quot;
  
    kafka:
      image: wurstmeister/kafka
      ports:
        - &quot;9092:9092&quot;
      depends_on:
        - zookeeper
      environment:
        KAFKA_ADVERTISED_HOST_NAME: 192.168.1.7
        KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
        KAFKA_CREATE_TOPICS: &quot;mytopic:1:1&quot;
  
  </code></pre>
  <p>192.168.1.7 is my ip that i got from ifconfig.</p>
  <p><a href="https://i.stack.imgur.com/pxJbf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pxJbf.png" alt="enter image description here" /></a></p>
  <p>In my service i am giving broker as 192.168.1.7:9092.</p>
  <p>When i do docker ps and exec to my kafka container. I am not able to access the 192.168.1.0</p>
  <p><a href="https://i.stack.imgur.com/5ElpE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5ElpE.png" alt="enter image description here" /></a></p>
  <p>What am i doing wrong here though the strange thing is in my application logs i see that the topic is created.</p>
  <p>When i try to create the topic:</p>
  <p><a href="https://i.stack.imgur.com/mX8bs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mX8bs.png" alt="enter image description here" /></a></p>