Understanding Gunicorn and Flask on Docker/Docker-Compose

Viewed 14233

I'm having trouble getting Flask and Gunicorn to work properly on Docker using Docker-compose

Dockerfile:

FROM ubuntu:latest
MAINTAINER Kyle Calica "Kyle Calica"
RUN apt-get update -y
RUN apt-get install -y python3-dev  build-essential python-pip gunicorn
RUN pip install --upgrade setuptools
RUN pip install ez_setup
COPY . /app
WORKDIR /app
RUN pip install -r ./app/requirements.txt
CMD [ "gunicorn", "-b", ":8000", "run" ]

Docker-Compose.yml:

version: '2'
services:
 web:
  build: .
  volumes:
  - ./:/var/www/crypto
  ports:
   - "5000:5000"

run.py:

from app import app
app.run()

From my understanding the Gunicorn master will run at port 8000 on all interfaces in the container

And then it'll spawn a node to run at port 5000 in the container at 127.0.0.1/localhost.

From there I link port 5000 in the container to my hostport 8000

I expected to see my application from my host computer at http://127.0.0.1:8000 instead nothing happened and nothing seemed to be connecting.

I have done this before but can't remember what I did differently.

(env) paper-street:CoinSlack kyle$ gunicorn -b :8000 run [2017-09-16 17:43:59 -0700] [15402] [INFO] Starting gunicorn 19.7.1 [2017-09-16 17:43:59 -0700] [15402] [INFO] Listening at: http://0.0.0.0:8000 (15402) [2017-09-16 17:43:59 -0700] [15402] [INFO] Using worker: sync [2017-09-16 17:43:59 -0700] [15405] [INFO] Booting worker with pid: 15405 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

^the reason why is because it seems like it spawned a worker and is running it at port 5000, i can't access my app through port 8000

2 Answers
Related