title: "Connection Refused" on Docker node container
body: <p>I am attempting to run a simple Angular 1.5 app on my Mac within the a custom image built from the official Node image <a href="https://hub.docker.com/_/node/" rel="nofollow noreferrer">here</a> but I get a "Connection Refused" error when attempting to access the site running inside the container. I am able to run the Angular app locally on my Mac with no error.</p>
  
  <p>Here is my Dockerfile:</p>
  
  <pre><code>FROM        node
  COPY        . /var/www
  WORKDIR     /var/www
  RUN         npm install
  EXPOSE      8888
  ENTRYPOINT ["npm", "start"]
  </code></pre>
  
  <p>In package.json, "npm start" is set to spin up the site on port 8888:</p>
  
  <pre><code>"start": "http-server -a localhost -p 8888 -c-1 ./app",
  </code></pre>
  
  <p>I built the custom image like this:</p>
  
  <pre><code>$docker build -t beerdb-web .
  </code></pre>
  
  <p>The image builds successfully:</p>
  
  <pre><code>$docker images
  REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
  beerdb-web          latest              cf406b4dacc7        13 minutes ago      760.6 MB
  </code></pre>
  
  <p>I then launch a container from the image like so:</p>
  
  <pre><code>$docker run -p 8888:8888 -d cf
  </code></pre>
  
  <p>The contaier appears to be running fine and is properly mapping the container port 8888 to the docker machine port 8888:</p>
  
  <pre><code>$docker ps
  CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                    NAMES
  828aeb67bc73        cf                  "npm start"         2 seconds ago       Up 2 seconds        0.0.0.0:8888-&gt;8888/tcp   condescending_almeida
  </code></pre>
  
  <p>I can inspect the container and see that it has an IP address and port 8888 exposed:</p>
  
  <pre><code>"NetworkSettings": {
     "Bridge": "",
     "SandboxID": "0d7180998a7c0bceb0c911069538f29297422fdf98bb859eba78e6584ce65919",
     "HairpinMode": false,
     "LinkLocalIPv6Address": "",
     "LinkLocalIPv6PrefixLen": 0,
     "Ports": {
         "8888/tcp": [
             {
                 "HostIp": "0.0.0.0",
                 "HostPort": "8888"
             }
         ]
     },
     "SandboxKey": "/var/run/docker/netns/0d7180998a7c",
     "SecondaryIPAddresses": null,
     "SecondaryIPv6Addresses": null,
     "EndpointID": "99bc9f9fad5a2445687327d45fb4fe29fb8267b08f119d3912720ced48b7d074",
     "Gateway": "172.17.0.1",
     "GlobalIPv6Address": "",
     "GlobalIPv6PrefixLen": 0,
     "IPAddress": "172.17.0.2",
     "IPPrefixLen": 16,
     "IPv6Gateway": "",
     "MacAddress": "02:42:ac:11:00:02",
     "Networks": {
         "bridge": {
             "IPAMConfig": null,
             "Links": null,
             "Aliases": null,
             "NetworkID": "41b55572b74543f33c99b3f86339ad4c81e9abaacbe0e92077f36cacae29a9c0",
             "EndpointID": "99bc9f9fad5a2445687327d45fb4fe29fb8267b08f119d3912720ced48b7d074",
             "Gateway": "172.17.0.1",
             "IPAddress": "172.17.0.2",
             "IPPrefixLen": 16,
             "IPv6Gateway": "",
             "GlobalIPv6Address": "",
             "GlobalIPv6PrefixLen": 0,
             "MacAddress": "02:42:ac:11:00:02"
         }
     }
  }
  </code></pre>
  
  <p>My machine appears fine as well:</p>
  
  <pre><code>$docker-machine ls
  NAME      ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER    ERRORS
  default   *        virtualbox   Running   tcp://192.168.99.100:2376           v1.12.3   
  </code></pre>
  
  <p>But when I navigate to <a href="http://192.168.99.100:8888/" rel="nofollow noreferrer">http://192.168.99.100:8888/</a> from my Mac I get "Connection Refused".</p>
  
  <p>In the snippet below I have ssh'd into the docker machine. You'll see that I can ping the IP address of the container, but when I use curl to try and hit port 8888 I get connection refused:</p>
  
  <pre><code>$docker-machine ssh
                          ##         .
                    ## ## ##        ==
                 ## ## ## ## ##    ===
             /"""""""""""""""""\___/ ===
        ~~~ {~~ ~~~~ ~~~ ~~~~ ~~~ ~ /  ===- ~~~
             \______ o           __/
               \    \         __/
                \____\_______/
   _                 _   ____     _            _
  | |__   ___   ___ | |_|___ \ __| | ___   ___| | _____ _ __
  | '_ \ / _ \ / _ \| __| __) / _` |/ _ \ / __| |/ / _ \ '__|
  | |_) | (_) | (_) | |_ / __/ (_| | (_) | (__|   &lt;  __/ |
  |_.__/ \___/ \___/ \__|_____\__,_|\___/ \___|_|\_\___|_|
  Boot2Docker version 1.12.3, build HEAD : 7fc7575 - Thu Oct 27 17:23:17 UTC 2016
  Docker version 1.12.3, build 6b644ec
  docker@default:~$ ping 172.17.0.2
  PING 172.17.0.2 (172.17.0.2): 56 data bytes
  64 bytes from 172.17.0.2: seq=0 ttl=64 time=0.092 ms
  64 bytes from 172.17.0.2: seq=1 ttl=64 time=0.092 ms
  ^C
  --- 172.17.0.2 ping statistics ---
  2 packets transmitted, 2 packets received, 0% packet loss
  round-trip min/avg/max = 0.092/0.092/0.092 ms
  docker@default:~$ 
  docker@default:~$ curl 172.17.0.2:8888
  curl: (7) Failed to connect to 172.17.0.2 port 8888: Connection refused
  docker@default:~$ 
  </code></pre>
  
  <p>To make sure the site is running properly within the container I launched a command prompt into the container and used curl to hit localhost:8888 and my web site's home page was returned.</p>
  
  <p>I believe that the custom image with built properly from the node base image and that it is functioning as expected. I believe there is a problem with either the port mapping or with the machine itself. I have a basic install of the Docker toolkit on my Mac and have not made any changes to the Default machine that runs inside VirtualBox, yet I still cannot access the web site running inside my container. </p>
  
  <p>Very frustrated, any help is appreciated.</p>