title: Docker not expose ports for node and webpack dev-server
body: <p>I have MacOS High Sierra and my goal is to run node web-applications without installation node on macos (I wanna use docker to do it). That web-application is usually angular-webpack (compilation + run dev serwer). </p>
  
  <p><strong>Dockerfile</strong>:</p>
  
  <pre><code>FROM node
  WORKDIR /work
  CMD while true; do sleep 10000; done
  EXPOSE 3002
  </code></pre>
  
  <p>The line <code>CMD while ...</code> makes that container will be not killed by docker after run it - this allow us to "login" into container (by <code>docker exec -it...</code>). </p>
  
  <p>Bash script <strong>run.cmd</strong> which run container:</p>
  
  <pre><code>set -e
  docker build -t node-cmd .
  docker rm -f node-cmd |:
  docker run -d --name node-cmd -p 3002:3002 -v /Volumes/work:/work node-cmd
  docker exec -it node-cmd /bin/bash
  </code></pre>
  
  <p>Where <code>/Volumes/work</code> is directory on my MacOs which contains angular projects.</p>
  
  <p>Here is example application in file <strong>/work/tmp/example.js</strong> (mapped in container) for which problem is visible (however them main goal is to find proper configuration of webpack dev-server):</p>
  
  <pre><code>var http = require('http');
  
  http.createServer(function (req, res) {
      res.writeHead(200, {'Content-Type': 'text/plain'});
      res.end('Hello World\n'+new Date);
  }).listen(3002, '127.0.0.1');
  
  console.log('Server running at http://127.0.0.1:3002/');
  </code></pre>
  
  <p>So first I run <code>run.cmd</code> - here is what <code>docker ps</code> write:</p>
  
  <pre><code>CONTAINER ID        IMAGE               COMMAND                   CREATED             STATUS              PORTS                    NAMES
  e22188d8e136        node-cmd            "/bin/sh -c 'echo \"R…"   16 seconds ago      Up 15 seconds       0.0.0.0:3002-&gt;3002/tcp   node-cmd
  </code></pre>
  
  <p>Inside container I type commands:</p>
  
  <pre><code>root@5cd3773e7815:/work# cd tmp
  root@5cd3773e7815:/work# node example.js &amp; 
  [1] 18
  root@5cd3773e7815:/work/tmp# Server running at http://127.0.0.1:3002/
  </code></pre>
  
  <p>So serwer was start. Now I test: </p>
  
  <pre><code>root@5cd3773e7815:/work/tmp# curl 127.0.0.1:3002
  Hello World
  </code></pre>
  
  <p>So inside docker everything works fine. Now when I go to my macos Chrome browser <code>http://127.0.0.1:3002</code> i get </p>
  
  <blockquote>
    <p>This page isn’t working 127.0.0.1 didn’t send any data.</p>
    
    <p>ERR_EMPTY_RESPONSE</p>
  </blockquote>
  
  <p>If I remove <code>-p 3002:3002</code> from <strong>run.cmd</strong> file the browser response change to</p>
  
  <blockquote>
    <p>127.0.0.1 refused to connect. Try: Checking the connection Checking the proxy and the firewall </p>
    
    <p>ERR_CONNECTION_REFUSED</p>
  </blockquote>
  
  <p>I also try tu use <code>docker run --ip=127.0.0.1...</code> but I get message that </p>
  
  <blockquote>
    <p>docker: Error response from daemon: user specified IP address is
    supported on user defined networks only.</p>
  </blockquote>
  
  <p>When i try to use <code>docker run --net=host ...</code> it doesn't change anything</p>
  
  <p>I alswo wanna mention that when I run <code>mysql</code> image by <code>docker run -p 3306:3306 ...</code> I works properly (!) - so may be the problem is with <code>node</code> image (?)</p>
  
  <p>Questions:</p>
  
  <ol>
  <li>How to "unblock" port 3002 in container to allow host browser to connect with service inside container?</li>
  <li>How to use subdomains like <code>subdomain.local:3002</code> too?</li>
  <li>How to use subdomains using <strong>webpack devServer</strong> (used in angular) instead above <code>example.js</code> (i need to have run many angular web-application each on different port with individual subdomain) ?</li>
  </ol>