title: Cannot connect Kafka running in docker
body: <p>I have the below configuration in docker compose yml file for advertised listeners</p>
  
  <p>My docker-compose.yml</p>
  
  <pre><code>  version: '2'
    services:
    zookeeper:
    image: confluentinc/cp-zookeeper:latest
    network_mode: host
    environment:
    ZOOKEEPER_CLIENT_PORT: 32181
    ZOOKEEPER_TICK_TIME: 2000
  extra_hosts:
    - "moby:127.0.0.1"
  
  kafka:
  image: confluentinc/cp-kafka:latest
  network_mode: host
  depends_on:
    - zookeeper
  environment:
    KAFKA_BROKER_ID: 1
    KAFKA_ZOOKEEPER_CONNECT: localhost:32181
    KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://lnc52c9:29092
    KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
  extra_hosts:
    - "moby:127.0.0.1"
  </code></pre>
  
  <p>and I connect this kafka using below property </p>
  
  <pre><code>props.put("bootstrap.servers", "lnc52c9:29092"); 
  </code></pre>
  
  <p>when I try to produce message in that server I am getting the below error </p>
  
  <blockquote>
    <p>WARN  o.apache.kafka.clients.NetworkClient - Error while fetching metadata with correlation id 1 : {foo=LEADER_NOT_AVAILABLE}</p>
  </blockquote>
  
  <p>The host is ping- able from my machine because its all in the same network ,no firewall issues. when I use the command <code>hostname</code> in the docker container I can see the same host name. Am I missing something?</p>