Docker Community Forums

Share and learn in the Docker community.

Flask app won't load in browser after executing docker-compose up

I am trying to learn to deploy apps using docker. I have a flask app I am trying to deploy. Each time I run docker-compose up, the output doesn’t show any errors but the app won’t load in the browser. I make use of flask-sqlalchemy to connect to a mysql database. The contents of my docker-compose file are as follows:

version: "3.7"

  image: mysql:5.7
     - "32000:3306"
     MYSQL_HOST: db
     MYSQL_USER: root
     MYSQL_ROOT_PASSWORD: data_scientist
      - ./db/route_client.sql:/docker-entrypoint-initdb.d/route_client.sql:ro


 build: C:\abdul_files\flask_apps\leaflet\control_search
   - db
   - "5001:5000"
   - db

The contents of my Dockerfile are as follows:

# Use an official Python runtime as an image
  FROM python:2.7.9

# The EXPOSE instruction indicates the ports on which a container 
# will listen for connections
# Since Flask apps listen to port 5000  by default, we expose it
  EXPOSE 5000

# Sets the working directory for following COPY and CMD instructions
# Notice we haven’t created a directory by this name - this instruction 
# creates a directory with this name if it doesn’t exist
  WORKDIR /control_search

# Install any needed packages specified in requirements.txt
  COPY requirements.txt /control_search
  RUN pip install -r requirements.txt

# Run when the container launches
  COPY . /control_search
  CMD python

The contents of my config file where I have my sqlalchemy database uri are as follows:

import os

class Config(object):
     SQLALCHEMY_DATABASE_URI = 'mysql://root:data_scientist@db/route_client'
     SECRET_KEY = os.urandom(32)
     SESSION_TYPE = 'filesystem'

My flask statement is as follows:

I am using Windows 10, so the Docker Dashboard launches MS Edge broswer by default. When I launch the app I get a “Hmmm…can’t reach this page” message in the browser. Any pointers to what I am doing wrong will be greatly appreciated.