<p>The application inside the container is inaccessible from the outside i.e if I exec into the docker container and do </p>

<pre class="lang-sh prettyprint-override"><code>curl localhost:5000 
</code></pre>

<p>it works correctly but not on the browser in my computer i get error : This site cant be reached</p>

<p>My Dockerfile:</p>

<pre><code># Use an official Python runtime as a parent image
FROM python:3.7-slim

# Set the working directory to /app
WORKDIR /web-engine

# Copy the current directory contents into the container at /app
COPY . /web-engine

# Install Gunicorn3
RUN apt-get update &amp;&amp; apt-get install default-libmysqlclient-dev gcc -y

# Install any needed packages specified in requirements.txt
RUN pip3 install --trusted-host pypi.python.org -r requirements.txt

# Make port 5000 available to the world outside this container
EXPOSE 5000

# Define environment variable
ENV username root

# Run app.py when the container launches
CMD gunicorn --workers 4 --bind 127.0.0.1:5000 application:app --threads 1

</code></pre>

<p>UPON executing docker in this way:</p>

<pre class="lang-sh prettyprint-override"><code>sudo docker run -e password=$password -p 5000:5000 $reg/web-engine:ve0.0.2
</code></pre>

<p>I get the following output:</p>

<pre><code>[2019-09-08 11:53:36 +0000] [6] [INFO] Starting gunicorn 19.9.0
[2019-09-08 11:53:36 +0000] [6] [INFO] Listening at: http://127.0.0.1:5000 (6)
[2019-09-08 11:53:36 +0000] [6] [INFO] Using worker: sync
[2019-09-08 11:53:36 +0000] [9] [INFO] Booting worker with pid: 9
[2019-09-08 11:53:36 +0000] [10] [INFO] Booting worker with pid: 10
[2019-09-08 11:53:36 +0000] [11] [INFO] Booting worker with pid: 11
[2019-09-08 11:53:36 +0000] [12] [INFO] Booting worker with pid: 12
</code></pre>

<p>So as you can see I'm mapping port 5000 of the container to port 5000 of my computer but localhost:5000 is not working</p>

<p>Therefore i tried everthing the same but with the development server of Flask
with the following change in My dockerfile </p>

<p>FRom</p>

<pre class="lang-sh prettyprint-override"><code>CMD gunicorn --workers 4 --bind 127.0.0.1:5000 application:app --threads 1

</code></pre>

<p>TO </p>

<pre class="lang-sh prettyprint-override"><code>CMD python3.7 application.py
</code></pre>

<p>and IT WORKED; I goto localhost:5000 and see the application is working</p>

<p>There is nothing wrong with the application. I suppose there's an error in gunicorn server</p>

<p>the requirements.txt file :</p>

<pre><code>Flask
Flask-SQLAlchemy
mysqlclient
gunicorn
bs4
html5lib
</code></pre>

<p>Please help me out</p>

<p>I also tried different forms of gunicorn and docker run command combinations like</p>

<pre class="lang-sh prettyprint-override"><code>CMD gunicorn -application:app &amp;&amp; sudo docker run -e password=$password -p 5000:8000 $reg/web-engine:ve0.0.2
</code></pre>

<p>It didnt work
<a href="https://i.stack.imgur.com/Z6ors.png" rel="noreferrer">terminal image of container working with development server</a></p>

<p>I would appreciate a solution involving nothing outside whats mentioned here like nginx, supervisor etc
 SOmeone please helllppp meeeeee.......😢</p>

cosmicsage
<p>By default, 127.0.0.1 means a different thing inside the container than it does outside. Use <code>0.0.0.0:5000</code> instead.</p>
