I have a flask application and I am trying to run it inside of a docker container using gunicorn.
This is my dockerfile
FROM python:3.6
WORKDIR /app
COPY ./requirements.txt /.requirements.txt
COPY . /app
# Install any needed packages specified in requirements.txt
RUN pip install -r requirements.txt
EXPOSE 8000
ENV FLASK_APP=<some_name>
ENV FLASK_ENV=development
CMD gunicorn -b :8000 -w 4 app:app
This is how I am running the container -
docker run <name>
And this is how I am testing it-
curl -X POST http://172.17.0.2:8000/login -H 'cache-control: no-cache' -H 'content-type: application/json' -d '<SOME_PAYLOAD>'
curl: (7) Failed to connect to 172.17.0.2 port 8000: Operation timed out
I've looked through a couple of answers on this site
As far as I can tell, I am
- Exposing the port
- Hitting the right IP
- Hitting the right port on my host computer
- Mapping the port on my host computer to my docker container.
Why is this operation timing out?
I have also tried
CMD gunicorn -b 0.0.0.0:8000 -w 4 app:app
which should map everythingdocker run -p 8000:8000 iterative
, which should force the mapping between the ports on the host and the container.
But to no avail.
On my computer the app works fine.
Why is it not working in the docker container?