Public Repository

Last pushed: a year ago
Short Description
Docker python-slim image with uWSGI and Nginx for Flask applications in Python
Full Description

Creating a Flask project with Docker

Note: These instructions are for the flask tag and are intended for a general purpose Flask web application.


Or you may follow the instructions to build your project from scratch:

  • Go to your project directory
  • Create a Dockerfile with:
FROM sicnarf/slim-uwsgi-nginx-flask

COPY ./app /app
  • Create an app directory and enter in it
  • Create a main.py file (it should be named like that and should be in your app directory) with:
from flask import Flask
app = Flask(__name__)

@app.route("/")
def hello():
    return "Hello World from Flask"

if __name__ == "__main__":
    app.run(host='0.0.0.0', debug=True, port=80)

the main application object should be named app (in the code) as in this example.

  • Go to the project directory (in where your Dockerfile is, containing your app directory)
  • Build your Flask image:
docker build -t myimage .
  • Run a container based on your image:
docker run -d --name mycontainer -p 80:80 myimage
Docker Pull Command
Owner
sicnarf

Comments (0)