Auto reloading flask server on Docker

Flask supports code reload when in debug mode as you’ve already done. The problem is that the application is running on a container and this isolates it from the real source code you are developing. Anyway, you can share the source between the running container and the host with volumes on your docker-compose.yaml like this:

Here is the docker-compose.yaml

version: "3"
services:
  web:
    build: ./web
    ports: ['5000:5000']
    volumes: ['./web:/app']

And here the Dockerfile:

FROM python:alpine

EXPOSE 5000

WORKDIR app

COPY * /app/

RUN pip install -r requirements.txt

CMD python app.py

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)