title: Docker overlay network publish only some of listed ports
body: <p>I am struggling with publishing ports in docker overlay networking while setting up a hadoop cluster. I would like to publish some of ports of a hadoop master container with the following command:</p>
  
  <pre><code>docker run -itd --name hadoop-master --hostname hadoop-master --network hadoop \
                                      -p 8088:8088 -p 50070:50070 -p 50090:50090 \
                                      -p 8080:8080 -p 18080:18080 -p 4040:4040 \
                                      hadoop-img
  </code></pre>
  
  <p>But for some reason only the :18080 port is accessible via the browser. I am sure that all the services are running inside the docker container.</p>
  
  <p>When I am inside the hadoop-master container and run:</p>
  
  <pre><code>curl -v localhost:18080
  </code></pre>
  
  <p>or </p>
  
  <pre><code>curl -v hadoop-master:18080
  </code></pre>
  
  <p>I get the same positive response (some html is displayed on the console), but when I want to do the same for port, let's say :50070 (or any other published) it is accessible only via host name i.e.:</p>
  
  <pre><code>curl -v hadoop-master:50070 -&gt; displays correct html response
  </code></pre>
  
  <p>but when using localhost like:</p>
  
  <pre><code>curl -v localhost:50070
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code> About to connect() to localhost port 50070 (#0)
  *   Trying ::1...
  * Connection refused
  *   Trying 127.0.0.1...
  * Connection refused
  * Failed connect to localhost:50070; Connection refused
  * Closing connection 0
  curl: (7) Failed connect to localhost:50070; Connection refused
  </code></pre>
  
  <p>So my guess is that the port :50070 is not mapped correctly inside the docker container into localhost. I have no idea why this happens. For some reason ports are published correctly while not using overlay networking. Could you please help me to solve my issue? Would be nice to have web UI's accessible.</p>
  
  <hr>
  
  <p>my hdfs-site.xml looks like:</p>
  
  <pre><code>&lt;configuration&gt;
  
      &lt;property&gt;
          &lt;name&gt;dfs.replication&lt;/name&gt;
          &lt;value&gt;1&lt;/value&gt;
      &lt;/property&gt;
      &lt;property&gt;
          &lt;name&gt;dfs.namenode.name.dir&lt;/name&gt;
          &lt;value&gt;file:///usr/local/hadoop/hdfs/namenode&lt;/value&gt;
      &lt;/property&gt;
      &lt;property&gt;
          &lt;name&gt;dfs.datanode.data.dir&lt;/name&gt;
          &lt;value&gt;file:///usr/local/hadoop/hdfs/datanode&lt;/value&gt;
      &lt;/property&gt;
  
      &lt;!-- HA SETUP --&gt;
      &lt;property&gt;
          &lt;name&gt;dfs.nameservices&lt;/name&gt;
          &lt;value&gt;hadoopcluster&lt;/value&gt;
      &lt;/property&gt;
  
      &lt;property&gt;
          &lt;name&gt;dfs.ha.namenodes.hadoopcluster&lt;/name&gt;
          &lt;value&gt;nn1,nn2&lt;/value&gt;
      &lt;/property&gt;
  
      &lt;property&gt;
          &lt;name&gt;dfs.namenode.rpc-address.hadoopcluster.nn1&lt;/name&gt;
          &lt;value&gt;hadoop-master-1:8020&lt;/value&gt;
      &lt;/property&gt;
      &lt;property&gt;
          &lt;name&gt;dfs.namenode.rpc-address.hadoopcluster.nn2&lt;/name&gt;
          &lt;value&gt;hadoop-master-2:8020&lt;/value&gt;
      &lt;/property&gt;
  
      &lt;property&gt;
          &lt;name&gt;dfs.namenode.http-address.hadoopcluster.nn1&lt;/name&gt;
          &lt;value&gt;hadoop-master-1:50070&lt;/value&gt;
      &lt;/property&gt;
      &lt;property&gt;
          &lt;name&gt;dfs.namenode.http-address.hadoopcluster.nn2&lt;/name&gt;
          &lt;value&gt;hadoop-master-2:50070&lt;/value&gt;
      &lt;/property&gt;
  
      &lt;property&gt;
          &lt;name&gt;dfs.namenode.shared.edits.dir&lt;/name&gt;
          &lt;value&gt;qjournal://hadoop-jn-1:8485;hadoop-jn-2:8485;hadoop-jn-3:8485/hadoopcluster&lt;/value&gt;
      &lt;/property&gt;
  
      &lt;property&gt;
          &lt;name&gt;dfs.client.failover.proxy.provider.hadoopcluster&lt;/name&gt;
          &lt;value&gt;org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider&lt;/value&gt;
      &lt;/property&gt;
  
      &lt;property&gt;
          &lt;name&gt;dfs.ha.fencing.methods&lt;/name&gt;
          &lt;value&gt;shell(/bin/true)&lt;/value&gt;
      &lt;/property&gt;
  
      &lt;property&gt;
          &lt;name&gt;dfs.journalnode.edits.dir&lt;/name&gt;
          &lt;value&gt;/opt/HDPV2/journal/node/local/data&lt;/value&gt;
      &lt;/property&gt;
  
      &lt;!-- ZOOKEEPER SETUP --&gt;
  
       &lt;property&gt;
          &lt;name&gt;dfs.ha.automatic-failover.enabled&lt;/name&gt;
          &lt;value&gt;true&lt;/value&gt;
      &lt;/property&gt;
  
       &lt;property&gt;
          &lt;name&gt;ha.zookeeper.quorum&lt;/name&gt;
          &lt;value&gt;zookeeper-1:2181,zookeeper-2:2181,zookeeper-3:2181&lt;/value&gt;
      &lt;/property&gt;
  
  &lt;/configuration&gt;
  
  </code></pre>
  
  <p>So far I have created a basic setup that runs all the services in separate containers spread across two docker hosts:</p>
  
  <ul>
  <li>3 x zookeeper containers</li>
  <li>3 x journal nodes containers</li>
  <li>2 x master containers (resource manager, namenode, HistoryServer and DFSZKFailoverController)</li>
  <li>3 x slave containers (datanode and nodemanager)</li>
  </ul>