title: Unable to access web application that's running in container built on docker
body: <p>I have a simple python program that does the following</p>
  
  <p><strong>identitydock.py</strong></p>
  
  <pre><code>from flask import Flask
  app = Flask(__name__)
  
  
  @app.route('/')
  def hello_world():
      return 'Hello Docker!\n'
  
  if __name__ == '__main__':
      app.run(debug=True, host='0.0.0.0')
  </code></pre>
  
  <p>My Dockerfile is as follows</p>
  
  <p><strong>Dockerfile</strong></p>
  
  <pre><code>FROM python:3.4
  
  RUN groupadd -r uwsgi &amp;&amp; useradd -r -g uwsgi uwsgi
  RUN pip install Flask==0.10.1 uWSGI==2.0.8
  WORKDIR /app
  COPY app /app
  COPY cmd.sh /
  
  EXPOSE 9090 9191
  USER uwsgi
  
  CMD ["/cmd.sh"]
  </code></pre>
  
  <p>my <strong>cmd.sh</strong> is as follows:</p>
  
  <pre><code>#!/bin/bash
  set -e
  
  if [ "$ENV" = 'DEV' ]; then
    echo "Running Development Server"
    exec python "identidock.py"
  else
    echo "Running Production Server"
    exec uwsgi --http 0.0.0.0:9090 --wsgi-file /app/identidock.py \
               --callable app --stats 0.0.0.0:9191
  fi
  </code></pre>
  
  <p>A simple web page that should return 'hello docker' for some reason does not work when I run using docker.</p>
  
  <p>The commands I gave to run the application:</p>
  
  <blockquote>
    <p>docker build -t identidock . </p>
    
    <p>docker run -d -p 5000:5000 identidock</p>
  </blockquote>
  
  <p>When I do curl localhost:5000 I get the following message</p>
  
  <blockquote>
    <p>curl: (7) Failed to connect to localhost port 5000: Connection refused</p>
  </blockquote>
  
  <p>May I know if there is an issue with my docker configuration?</p>
  
  <p>I am using the following docker version on MacOSX</p>
  
  <blockquote>
    <p>Docker version 17.03.1-ce, build c6d412e</p>
  </blockquote>
  
  <p>Reference source 
  <a href="https://github.com/using-docker/using_docker_in_dev" rel="nofollow noreferrer">https://github.com/using-docker/using_docker_in_dev</a></p>
  
  <p><strong>Edit -1</strong></p>
  
  <p>On docker ps -a , the container status shows 'UP'</p>
  
  <p>on docker logs CONTAINER_ID, i get the following logs</p>
  
  <pre><code>Running Production Server
  *** Starting uWSGI 2.0.8 (64bit) on [Thu Jul  6 02:04:04 2017] ***
  compiled with version: 4.9.2 on 06 July 2017 02:03:16
  os: Linux-4.4.74-boot2docker #1 SMP Mon Jun 26 18:01:14 UTC 2017
  nodename: 323e6ff35d0d
  machine: x86_64
  clock source: unix
  pcre jit disabled
  detected number of CPU cores: 1
  current working directory: /app
  detected binary path: /usr/local/bin/uwsgi
  your processes number limit is 1048576
  your memory page size is 4096 bytes
  detected max file descriptor number: 1048576
  lock engine: pthread robust mutexes
  thunder lock: disabled (you can enable it with --thunder-lock)
  uWSGI http bound on 0.0.0.0:9090 fd 4
  uwsgi socket 0 bound to TCP address 127.0.0.1:45710 (port auto-assigned) fd 3
  Python version: 3.4.6 (default, Jun 21 2017, 18:32:49)  [GCC 4.9.2]
  *** Python threads support is disabled. You can enable it with --enable-threads ***
  Python main interpreter initialized at 0x1bd9640
  your server socket listen backlog is limited to 100 connections
  your mercy for graceful operations on workers is 60 seconds
  mapped 145536 bytes (142 KB) for 1 cores
  *** Operational MODE: single process ***
  WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x1bd9640 pid: 1 (default app)
  *** uWSGI is running in multiple interpreter mode ***
  spawned uWSGI master process (pid: 1)
  spawned uWSGI worker 1 (pid: 6, cores: 1)
  *** Stats server enabled on 0.0.0.0:9191 fd: 13 ***
  spawned uWSGI http 1 (pid: 7)
  </code></pre>