title: Kafka Server issue in Docker
body: <p>I am using docker for my sample Spark + Kafka project in windows machine.
  I am facing</p>
  <pre><code>WARN ClientUtils: Couldn't resolve server kafka:9092 from bootstrap.servers as DNS resolution failed for kafka
  [error] (run-main-0) org.apache.kafka.common.KafkaException: Failed to construct kafka consumer
  [error] org.apache.kafka.common.KafkaException: Failed to construct kafka consumer
  ------
  Caused by: org.apache.kafka.common.config.ConfigException: No resolvable bootstrap urls given in bootstrap.servers
  </code></pre>
  <p>Below is my docker-compose.yml</p>
  <pre><code>version: '2'
  services:
      test1:
          build: test1service/.
          depends_on:
              - kafka
      test2:
          build: test2/.
          depends_on:
              - kafka
              - test1
      zookeeper:
          image: confluentinc/cp-zookeeper:5.1.0
          ports:
           - 2181:2181
          environment:
            ZOOKEEPER_CLIENT_PORT: 2181
            ZOOKEEPER_TICK_TIME: 2000
          extra_hosts:
            - &quot;localhost: 127.0.0.1&quot;
      kafka:
          image: confluentinc/cp-kafka:5.1.0
          ports:
           - 9092:9092
          depends_on:
            - zookeeper
          environment:
            KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
            KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
            #KAFKA_ADVERTISED_LISTENERS: LISTENER_DOCKER_INTERNAL://kafka:9092
            KAFKA_AUTO_CREATE_TOPICS_ENABLE: &quot;true&quot;
            KAFKA_DELETE_TOPIC_ENABLE: &quot;true&quot;
            KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
          extra_hosts:
            - &quot;localhost: 127.0.0.1&quot;
  </code></pre>
  <p>Below is my sample code in test2 service</p>
  <pre><code>val inputStreamDF = spark.readStream.format(&quot;kafka&quot;).option(&quot;kafka.bootstrap.servers&quot;, &quot;kafka:9092&quot;)
                             .option(&quot;subscribe&quot;, &quot;test1&quot;)
                             .option(&quot;startingOffsets&quot;, &quot;earliest&quot;)
                             .load()
  </code></pre>
  <p>docker ps command output is</p>
  <pre><code>CONTAINER ID   IMAGE                             COMMAND                  CREATED             STATUS          PORTS                                        NAMES
  4c8feb49e12b   test1                             &quot;/usr/bin/start.sh&quot;      About an hour ago   Up 50 minutes                                                test1
  4535ce246541   test2                             &quot;/usr/bin/myservice-…&quot;   About an hour ago   Up 50 minutes                                                test2
  733766f72adb   confluentinc/cp-kafka:5.1.0       &quot;/etc/confluent/dock…&quot;   About an hour ago   Up 51 minutes   0.0.0.0:9092-&gt;9092/tcp       kafka_1
  d915e25cb226   confluentinc/cp-zookeeper:5.1.0   &quot;/etc/confluent/dock…&quot;   About an hour ago   Up 51 minutes   2888/tcp, 0.0.0.0:2181-&gt;2181/tcp, 3888/tcp   zookeeper_1
  </code></pre>
  <p>Has anyone faced similar issue, how did you resolve?</p>