0

I have recently started learning API. I did all my projects on Ubuntu VM. I used flask for API and mongoDB to store my users input, all this in Docker. When I moved my code from VM to Windows, and installed Docker desktop I have been facing this issue of "not responding" / "The server at 172.20.0.3 is taking too long to respond."

vs code terminal output:

enter image description here

This is my file structure:

enter image description here

docker-compose.yml code:

version: '3'
services: 
  web:
    build: './web'
    ports: 
     - '5000:5000'
   links: 
     - db
  db:
    build: './db'

web/Dockerfile:

FROM python:3
WORKDIR /usr/src/app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
RUN python -m spacy download en_core_web_sm
COPY . .
CMD ["python","app.py"]

db/Dockerfile:

FROM mongo:3.6.4

To check the code for app.py please use my GitHub link. This issue is not just for this app, it is same for my other projects which I developed in Ubuntu Virtual machine.

James Z
  • 12,209
  • 10
  • 24
  • 44
hpal007
  • 191
  • 3
  • 20
  • How are you trying to reach your web server? Do you try to access 172.20.0.3 or localhost:9000? – Christian Fosli Aug 15 '21 at 16:14
  • 1
    @ChristianFosli http://172.20.0.3:5000/ – hpal007 Aug 15 '21 at 16:32
  • Does this answer your question? [Deploying a minimal flask app in docker - server connection issues](https://stackoverflow.com/questions/30323224/deploying-a-minimal-flask-app-in-docker-server-connection-issues) – OneCricketeer Aug 16 '21 at 03:53
  • 1) Unclear what you're expecting `2000:9000` to do when the default Flask port is 5000. 2) You're forwarding a host port into the container, and the container itself doesn't know that, so you cannot use the address that it prints; use `http://localhost:[port]` – OneCricketeer Aug 16 '21 at 03:56
  • @OneCricketeer, I have updated the code, the code in docker-compose.yml to 5000:5000, please don't get confuse – hpal007 Aug 16 '21 at 06:57
  • @OneCricketeer, I have already checked that link, my app.py have that implementation, you can check the Git-hub link in desc to check the code. Issue is not that I am doing it first time, i have used same docker in Ubuntu it works there. – hpal007 Aug 16 '21 at 07:02
  • 1
    Please keep your code in sync with the question here. Also refer [mcve]. Regardless, you should still be connecting to `http://localhost:5000`, and you should be using Docker Desktop if you're on Windows – OneCricketeer Aug 16 '21 at 08:59

0 Answers0