title: Cannot access nodejs app on browser at localhost:4200 (docker run -p 4200:4200 ....)
body: <p>Please I need some help, new to docker; have a feeling it's something minor I missed. </p>
  
  <p>I'm trying to run a nodejs app using a dockerfile and docker-compose; I'm on Ubuntu 17.04 LTS however, eventhough the status shows UP and runnning I can't access the app from <strong><em>localhost:4200</em></strong></p>
  
  <pre><code>docker-compose.yml
  version: '3'
  
  services:
   my-app:
      build:
        context: .
        dockerfile: Dockerfile
      restart: unless-stopped
      volumes:
        - .:/usr/src/app
      ports:
        - "4200:4200"
  </code></pre>
  
  <p><strong><em>docker ps</em></strong></p>
  
  <pre><code>CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS              PORTS                     NAMES
  e6a99aab4e37        my-app   "ng serve"               10 minutes ago      Up 10 minutes       0.0.0.0:4200-&gt;4200/tcp    my-app_1
  </code></pre>
  
  <p>I ran the following command and got an ip address, I used that ip:port# in browser but app won't show up: </p>
  
  <pre><code>docker inspect --format '{{ .NetworkSettings.IPAddress }}' 'my-app_1'
  </code></pre>
  
  <p>when I go to localhost:4200 it doesn't work; 
  I also tried: <code>docker run --rm -it -p 4200:4200 my_app_container</code> and it runs and I can see that npm start runs and listens on port 4200 but when I go to browser and type <code>localhost:4200</code> I get nothing, just: this site can't be reached; ERR_NAME_NOT_RESOLVED</p>
  
  <pre><code>  ubuntu17@ubuntu:~/playground/apps/my_app-ui$ docker images
  REPOSITORY            TAG                 IMAGE ID            CREATED             SIZE
  my_app   latest              d41d3d77811b        17 minutes ago      1.24GB
  nept0                 latest              df93134e2539        21 minutes ago      1.24GB
  node                  9                   c888d933885c        5 days ago          676MB
  registry              2.6.1               c2a449c9f834        6 months ago        33.2MB
  ubuntu17@ubuntu:~/playground/apps/my_app-ui$ docker run -it --rm -p 4200:4200 nept0
  ** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
  Date: 2018-01-16T15:46:19.502Z                                                          
  Hash: 00ec980debaf8e47350d
  Time: 12386ms
  chunk {inline} inline.bundle.js (inline) 5.79 kB [entry] [rendered]
  chunk {main} main.bundle.js (main) 270 kB [initial] [rendered]
  chunk {polyfills} polyfills.bundle.js (polyfills) 549 kB [initial] [rendered]
  chunk {styles} styles.bundle.js (styles) 511 kB [initial] [rendered]
  chunk {vendor} vendor.bundle.js (vendor) 11.8 MB [initial] [rendered]
  
  webpack: Compiled successfully.
  </code></pre>
  
  <p>LASTLY:
      - The weirdest thing is if I don't use docker and just build the app manually by simply running: <code>ng serve or npm serve</code> which looks into <code>package.json</code> -> script section and starts ng serve, then <code>localhost:4200</code> runs fine so I'm lost at to 1. </p>
  
  <p>Why I can't access <code>localhost:4200</code> or <code>ipaddress:4200</code> on browser when running via docker but it works if I build manually outside of docker by just running npm start?</p>