Public | Automated Build

Last pushed: 16 days ago
Short Description
This image can be used as a starting point to run django applications.
Full Description

Supported tags

  • latest, 2.0-python3
  • 2.0-python3-onbuild
  • 1.11-python3
  • 1.11-python3-onbuild
  • 1.11-python2
  • 1.11-python2-onbuild

About this image

This image can be used as a starting point to run django applications.
It uses gunicorn in the latest version to serve the wsgi application.
The container picks up the wsgi entry point based on the environment variable DJANGO_APP.

Django is already installed within the version specified by the image.
For example 2.0-python3 will contain the latest django version of 2.0.x.
The image does also ship with the latest version of pytz installed.

The image does export port 8000.

It has a volume defined to generate static resources at /var/www/static.
The volume /usr/django/app can be used for live reload during development.

The environment variable GUNICORN_RELOAD can be set to true to active live reload if a source file
does change.

If the following environment variables are set to true the corresponding django command will
be executing on container start:


How to use this image

Basic Setup

FROM alang/django
ENV DJANGO_APP=demo                # will start /usr/django/app/demo/
COPY src /usr/django/app

Using the onbuild image

The -onbuild variant of the image does assume that your build directory (directory where the
Dockerfile is located) contains a directory called src which is the place where the django source
code is. This directory will be copied to /usr/django/app.
The image does also assume that your source code contains a requirements.txt file in the src
directory. All dependencies listed there will be installed.

Create new django project

Bootstrap a new project called demo within the src folder:

docker run --rm -v "$PWD/src:/usr/django/app" alang/django django-admin startproject demo app

Executing one off commands

How to execute one off django commands like makemigrations:

docker run --rm -v "$PWD/src:/usr/django/app" alang/django python app/ makemigrations

Advanced Configuration

A custom gunicorn config can be included:

COPY gunicorn.conf /etc/gunicorn/

User Feedback


If you have any problems with or questions about this image, please contact me through a GitHub issue.


You are invited to contribute new features, fixes, or updates, large or small.
Please send me a pull request.

Docker Pull Command
Source Repository