title: Not able to access Flask Web application running inside a Docker container
body: <p>I have the following <code>Dockerfile</code>  where I build a docker image that contains <code>ElasticSearch</code>, <code>Kibana4</code> and <code>gunicorn</code></p>
  
  <pre><code># gunicorn-flask                                                                                                                                                                               
  FROM devdb/kibana
  
  MAINTAINER KS &lt;k.s@gmail.com&gt;
  
  ENV DEBIAN_FRONTEND noninteractive
  
  RUN apt-get update
  RUN apt-get install -y python python-pip python-virtualenv gunicorn
  RUN pip install -U pip 
  
  # Setup flask application
  RUN mkdir -p /deploy/app
  
  COPY gunicorn_config.py /deploy/gunicorn_config.py
  COPY app /deploy/app
  COPY run_gunicorn /etc/service/gunicorn
  
  RUN pip install -r /deploy/app/requirements.txt
  
  WORKDIR /deploy/app
  
  EXPOSE 5000 
  </code></pre>
  
  <p>The python <code>Flask</code> application and the <code>requirements.txt</code> which contains the dependencies are in a folder named <code>app</code> in the same path as the <code>Dockerfile</code>.</p>
  
  <p>I also have two files <code>gunicorn_config.py</code> and <code>run_gunicorn</code> in the same path.</p>
  
  <p>The contents of gunicorn_config.py is shown below.</p>
  
  <pre><code>    bind = "0.0.0.0:5000"
      workers = 2
  </code></pre>
  
  <p>The contents of <code>run_gunicorn</code> is shown below.</p>
  
  <pre><code>    #!/bin/bash
      cd /deploy/app
  </code></pre>
  
  <p>I build the docker image using</p>
  
  <pre><code>sudo docker build --rm -t es-kibana-gunicorn:test-10-07-15 .
  </code></pre>
  
  <p>I save the image to a tar file using</p>
  
  <pre><code>docker save 45a61ddf8d7e &gt; es-kb-gunicorn-13-07-15.tar
  </code></pre>
  
  <p>where <code>45a61ddf8d7e</code> is the Image ID.</p>
  
  <p>I copy it over to another server and I load the image and run the container.</p>
  
  <pre><code>CONTAINER ID        IMAGE                 COMMAND             CREATED             STATUS              PORTS                                                                              NAMES
  d62a16fcc398        45a61ddf8d7e:latest   "/sbin/my_init"     7 seconds ago       Up 6 seconds        0.0.0.0:5000-&gt;5000/tcp, 0.0.0.0:5601-&gt;5601/tcp, 0.0.0.0:9200-&gt;9200/tcp, 9300/tcp   determined_shockley   
  </code></pre>
  
  <p>On <code>port 5000</code> it does look like my <code>Flask web application</code> started by gunicorn is listening.</p>
  
  <p>If I try to do a <code>POST</code> to that webserver, I get the following error.</p>
  
  <pre><code>Traceback (most recent call last):
    File "update_txid.py", line 27, in &lt;module&gt;
      r = requests.post("http://192.168.132.125:5000", data=json_data,headers=headers)
    File "/usr/lib/python2.7/site-packages/requests/api.py", line 108, in post
      return request('post', url, data=data, json=json, **kwargs)
    File "/usr/lib/python2.7/site-packages/requests/api.py", line 50, in request
      response = session.request(method=method, url=url, **kwargs)
    File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 464, in request
      resp = self.send(prep, **send_kwargs)
    File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 576, in send
      r = adapter.send(request, **kwargs)
    File "/usr/lib/python2.7/site-packages/requests/adapters.py", line 415, in send
      raise ConnectionError(err, request=request)
  requests.exceptions.ConnectionError: ('Connection aborted.', error(111, 'Connection refused'))
  </code></pre>
  
  <p>It would be great if someone could help me figure out what is wrong here.
  I can access both port 5601 <code>Kibana4</code> and port 9200 'ElasticSearch`</p>