Skip to content
Snippets Groups Projects

docker-flask

A minimal docker image used to start flask application in development.

Usage

Supposing your flask application app.py is in /home/user/dev/test-flask:

docker run -p 8000:8000 --rm -v /home/user/dev/test-flask:/var/app:z

Notes:

  • z stands for selinux, you can omit if no selinux is used.
  • by default the image searches for an app.py. If you want to use a different name, set FLASK_APP env var. See Application Discovery.
  • if additional python packages are needed, just create a requirements.txt file with deps in your project root dir and they'll be installed at container startup

Sample app

from time import sleep
from flask import Flask

app = Flask(__name__)


@app.route("/")
def hello_world():
    return "<p>Hello, World!</p>"