title: Issue using NodeJS Kafka and Docker, the resolved host is container ID
body: <p>I have a CentOS 7.5 VM running and I am trying to run a ZooKeeper/Kafka server into a container (with docker compose).</p>
  
  <p>I am using kafka-node(2.6.1) to use Kafka. Everything works fine when running on the VM directly. But when the Kafak server is dockerized, there is an issue related to IPv6. </p>
  
  <p>I can create topics on the Kafka server when I use the <code>/bin/kafka-topics.sh</code> script when being outside the container (on the host) meaning that the container is OK and the port (2181, 9092) are opened.</p>
  
  <p>Here is the versions I'm using :</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>//CentOS Version
  SB Version:    :core-4.1-amd64:core-4.1-noarch
  Distributor ID: CentOS
  Description:    CentOS Linux release 7.5.1804 (Core)
  Release:        7.5.1804
  Codename:       Core
  
  //nodejs verison
  5.3.0
  
  //kafka version
  2.11-2.0.0
  
  // docker version
  Client:
   Version:           18.06.0-ce
   API version:       1.38
   Go version:        go1.10.3
   Git commit:        0ffa825
   Built:             Wed Jul 18 19:08:18 2018
   OS/Arch:           linux/amd64
   Experimental:      false
  Server:
   Engine:
    Version:          18.06.0-ce
    API version:      1.38 (minimum version 1.12)
    Go version:       go1.10.3
    Git commit:       0ffa825
    Built:            Wed Jul 18 19:10:42 2018
    OS/Arch:          linux/amd64
    Experimental:     false
    
  //docker compose version
  docker-compose version 1.21.2, build a133471
  docker-py version: 3.4.1
  CPython version: 2.7.5
  OpenSSL version: OpenSSL 1.0.2k-fips  26 Jan 2017</code></pre>
  </div>
  </div>
  </p>
  
  <p>Here is my nodejs script that works fine when the kafka is on the host but not when the kafka is in docker :</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var fs = require('fs'),
      kafka = require('kafka-node'),
      path = require('path'),
      cassandra = require('cassandra-driver'),
      moment = require('moment');
  //Producer
  const client = new kafka.Client("127.0.0.1:2181");
  
  const producer = new kafka.HighLevelProducer(client);
  var interval;
  console.log('Hello');
  
  producer.on("ready", function () {
      console.log("Ingestion Complete Event Producer is connected and ready.");
      interval = setInterval(function () {
          _scanDirectoryAndTagReport();
      }, (process.argv[2] || 1500));
  });
  producer.on('error', function(err) {
      console.log('error', err);
      
  });</code></pre>
  </div>
  </div>
  </p>
  
  <p>And here is the output i'm having when I run this script from the VM :</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>Hello
  Ingestion Complete Event Producer is connected and ready.
  error { Error: getaddrinfo ENOTFOUND d98e973bc4a7 d98e973bc4a7:9092
      at errnoException (dns.js:28:10)
      at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:79:26)
    code: 'ENOTFOUND',
    errno: 'ENOTFOUND',
    syscall: 'getaddrinfo',
    hostname: 'd98e973bc4a7',
    host: 'd98e973bc4a7',
    port: '9092' } 
  error { Error: getaddrinfo ENOTFOUND d98e973bc4a7 d98e973bc4a7:9092
      at errnoException (dns.js:28:10)
      at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:79:26)
    code: 'ENOTFOUND',
    errno: 'ENOTFOUND',
    syscall: 'getaddrinfo',
    hostname: 'd98e973bc4a7',
    host: 'd98e973bc4a7',
    port: '9092' } 
    error { Error: getaddrinfo ENOTFOUND d98e973bc4a7 d98e973bc4a7:9092
      at errnoException (dns.js:28:10)
      at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:79:26)
    code: 'ENOTFOUND',
    errno: 'ENOTFOUND',
    syscall: 'getaddrinfo',
    hostname: 'd98e973bc4a7',
    host: 'd98e973bc4a7',
    port: '9092' } 
    error { Error: getaddrinfo ENOTFOUND d98e973bc4a7 d98e973bc4a7:9092
      at errnoException (dns.js:28:10)
      at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:79:26)
    code: 'ENOTFOUND',
    errno: 'ENOTFOUND',
    syscall: 'getaddrinfo',
    hostname: 'd98e973bc4a7',
    host: 'd98e973bc4a7',
    port: '9092' } 
    error { Error: getaddrinfo ENOTFOUND d98e973bc4a7 d98e973bc4a7:9092
      at errnoException (dns.js:28:10)
      at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:79:26)
    code: 'ENOTFOUND',
    errno: 'ENOTFOUND',
    syscall: 'getaddrinfo',
    hostname: 'd98e973bc4a7',
    host: 'd98e973bc4a7',
    port: '9092' } 
    error { Error: getaddrinfo ENOTFOUND d98e973bc4a7 d98e973bc4a7:9092
      at errnoException (dns.js:28:10)
      at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:79:26)
    code: 'ENOTFOUND',
    errno: 'ENOTFOUND',
    syscall: 'getaddrinfo',
    hostname: 'd98e973bc4a7',
    host: 'd98e973bc4a7',
    port: '9092' } </code></pre>
  </div>
  </div>
  </p>
  
  <p>The error message is looping.</p>
  
  <p>Someone have a lead ? </p>
  
  <p>have a nice day, </p>
  
  <p>NeitoFR</p>
  
  <p>Edit 1 : As pointed out in the comment it is not a IPv6 related issue but the problem is that the resolved host by my producer is the container ID</p>