Auto reloading flask server on Docker

前端 未结 4 2217
南笙
南笙 2020-12-16 11:44

I want my flask server to detect changes in code and reload automatically. I\'m running this on docker container. Whenever I change something, I have to build and up again t

4条回答
  •  隐瞒了意图╮
    2020-12-16 11:49

    I managed to achieve flask auto reload in docker using docker-compose with the following config:

    version: "3"
    services:
      web:
        build: ./web
        entrypoint:
          - flask
          - run
          - --host=0.0.0.0
        environment:
          FLASK_DEBUG: 1
          FLASK_APP: ./app.py
        ports: ['5000:5000']
        volumes: ['./web:/app']
    

    You have to manually specify environment variables and entrypoint in the docker compose file in order to achieve auto reload.

提交回复
热议问题