Raoul
Raoul

Reputation: 2222

Django + Docker best practice: use runserver or wsgi.py?

I've been reading a lot of blog posts (like this one) on how to deploy Django in a containerized Docker environment.

They all use the runserver command in the docker-compose.yml.

Even the Docker documentation does this.

This suprises me, since using the Django web server is not recommended for production!

What is recommended is pointing the webserver to wsgi.py.

However, none of the articles I've found on Django and Docker explain why they use runserver instead of pointing apache or nginx to wsgi.py.

Why would all these articles use the built-in Django development webserver to handle requests, instead of a full blown webserver like apache or nginx?

Isn't the point of using containers in development, to keep that environment as close to production as possible? Then why build a not-production-ready environment?

Upvotes: 3

Views: 1344

Answers (1)

atline
atline

Reputation: 31664

The aim of most guides including this you given is to give you a ABC guide to containerize your django applicaiton quickly with docker.

When you decided to read these guides, you are certainly ansumed as experienced django developer, but a new docker user. So the emphasis of these article will not tell you how to use production server(like uwsgi, gunicorn) to manage your django application, because it assumes your are familiar with that.

As a new docker user, it will put more effort to tell you how to dockerize them in container with a start django project. Then, a simple hello-world-like project with development django http server will be the most suitable option.

But, you still need to use uwsgi, gunicorn etc to deploy you apps, E.g. https://hub.docker.com/r/dockerfiles/django-uwsgi-nginx

Upvotes: 2

Related Questions