Deploy Django using Docker Compose


Related posts

With the adaptation of micro-service architecture i.e. various components as independent services, docker community came up with docker-compose (previously FIg). Using a single (YAML) configuration file (docker-compose.yml) to specify all the components, which docker compose build and spawn as independent services i.e. docker containers.
Use-case: You have a web project, with web application developed using Django, using a Postgres database, redis as caching engine, and NginX for serving over the web. Using docker-compose you can deploy this stack with a single command:
docker-compose build --no-cache && docker-compose up
The complete project is available here.

This blog post is about using docker compose, for deploying your Django application with Postgres, Redis, and Nginx. It is presumed, you already have your Django project, and want to deploy your full stack.

High level steps

  1. Install and start Docker compose
  2. Setup project – presume you already have a Django project.
  3. Create Dockerfile(s) and docker-compose.yml
  4. Build service images – docker-compose build
  5. Create database and database migrations – docker-compose run web python manage.py migrate
  6. Start services containers – docker-compose up
  7. View in browser http://127.0.0.1

Continue reading “Deploy Django using Docker Compose”