Docker image with uWSGI and Nginx for Python applications (as Flask) in a single container.
This Docker image allows you to create Python web applications that run with uWSGI and Nginx in a single container.
uWSGI with Nginx is one of the best ways to deploy a Python application, so you you should have a good performance (check the benchmarks) with this image.
This image was created to be the base image for tiangolo/uwsgi-nginx-flask but could be used as the base image to run any Python web application.
If you are creating a new Flask web application you should use tiangolo/uwsgi-nginx-flask instead.
GitHub repo: https://github.com/tiangolo/uwsgi-nginx-docker
Docker Hub image: https://hub.docker.com/r/tiangolo/uwsgi-nginx/
- 2016-04-05: Nginx and uWSGI logs are now redirected to stdout, allowing to use
docker logs
.
You shouldn't have to clone the GitHub repo. You should use it as a base image for other images, using FROM tiangolo/uwsgi-nginx
in your Dockerfile
.
If you are building a Flask web application you should use instead tiangolo/uwsgi-nginx-flask.
One of the best ways to deploy a Python web application is with uWSGI and Nginx, as seen in the benchmarks.
Roughly:
-
Nginx is a web server, it takes care of the HTTP connections and also can serve static files directly and more efficiently.
-
uWSGI is an application server, that's what runs your Python code and it talks with Nginx.
-
Your Python code has the actual web application, and is run by uWSGI.
This image takes advantage of already slim and optimized existing Docker images (based on Debian as recommended by Docker) and implements Docker best practices.
It uses the official Python Docker image, installs uWSGI and on top of that, with the least amount of modifications, adds the official Nginx image (as of 2016-02-14).
And it controls all these processes with Supervisord.
There's the rule of thumb that you should have "one process per container".
That helps, for example, isolating an app and its database in different containers.
But if you want to have a "micro-services" approach you may want to have more than one process in one container if they are all related to the same "service", and you may want to include your Flask code, uWSGI and Nginx in the same container (and maybe run another container with your database).
That's the approach taken in this image.
This image has a default sample "Hello World" app in the container's /app
directory using the example in the uWSGI documentation.
You probably want to override it or delete it in your project.
It is there in case you run this image by itself and not as a base image for your own Dockerfile
, so that you get a sample app without errors.
This project is licensed under the terms of the Apache license.