Topic · Containers & orchestration

Docker & Compose for Django in production

Production Docker images for Django and Compose stacks that run them, with volumes, networks, and environment.

image layers, then containersyour codePython dependenciesPython runtimeslim base imageweb: gunicornworker: celeryrelease: migrateOne image, several roles; order layers so code changes rebuild only the top

Docker packages Django, its dependencies, and its runtime into one image. Getting that image small, secure, and correct for production is most of the work; Compose then runs it with its database and proxy.

The guides cover writing the Dockerfile, running Compose in production, registries and multi-arch builds, and the container-specific problems with environment variables, volumes, and static files.

33Set it up
3Run it well
1Check it
23Fix it

Set it up

Guides that take this from nothing to running in production.

  • Deploy Django with Docker Compose in Production

    Many Docker Compose examples for Django are built for local development, not production.

  • How to Dockerize a Django App for Production

    A Dockerized Django app that works in development is not automatically safe for production.

  • Deploy Django with Podman and Quadlet

    Run Django in rootless Podman containers managed by systemd with Quadlet: container, network, and volume units, Podman secrets, health checks, and auto-updates.

  • Build Multi-Architecture Django Docker Images

    Build Django images for both amd64 and arm64 (Graviton, Ampere, Apple Silicon) with docker buildx: QEMU versus native runners, wheels, caching in GitHub Actions, and verifying manifests.

  • Run Django Management Commands in Docker and Kubernetes

    Run Django manage.py commands against containerised deployments: docker compose exec versus run, kubectl exec versus one-off Jobs, loading the right settings and secrets, interactive shells, and keeping one-off commands out of web containers.

  • Write a Docker Entrypoint Script for Django

    Write a robust docker-entrypoint.sh for Django: wait for dependencies, optionally run migrations and collectstatic behind flags, support web, worker, and one-off commands, exec the final process for signals, and keep secrets out of logs.

  • Separate Dev and Prod With Docker Compose Override Files

    Use one compose.yaml for a Django stack with compose.override.yaml for development and compose.prod.yaml for production: bind mounts and runserver locally, built images, restart policies, and no exposed database ports in production.

  • Run a Django Docker Container as a Non-Root User

    Run Django containers as a non-root user: create a dedicated user in the Dockerfile, fix ownership of app, static, and media paths, handle volume permissions, bind high ports, and add a read-only root filesystem and dropped capabilities.

  • Use Docker Secrets With Django

    Pass Django secrets to containers as files instead of environment variables: Docker Compose and Swarm secrets mounted at /run/secrets, the _FILE convention, reading them in settings, and keeping secrets out of images and docker inspect.

  • Docker vs a Plain VPS for Django

    Should you deploy Django with Docker or directly on a VPS with systemd? Compare reproducibility, deploy workflow, performance, debugging, security updates, and team skills, with a recommendation for solo developers, small teams, and growing apps.

  • Deploy Django With Portainer Stacks

    Deploy a Django app with Portainer: define a Compose stack with web, worker, Postgres, and Redis, pull images from a private registry, set environment variables and secrets, enable Git-based redeploys or webhooks, and add a reverse proxy for HTTPS.

  • Deploy Django on HashiCorp Nomad

    Deploy Django on HashiCorp Nomad: write a job with web, worker, and migration tasks, pull Docker images, inject secrets from Vault or Nomad Variables with templates, register services, route traffic through Traefik or Consul, and roll out safely.

  • Build Django Images With Cloud Native Buildpacks

    Build production Django container images without a Dockerfile using Cloud Native Buildpacks and the pack CLI: choose a builder, configure Python version and start command with a Procfile, run collectstatic, rebase images for OS patches, and use it in CI.

  • Deploy django CMS to Production

    Deploy a django CMS site to production: configure settings for CMS and filer, PostgreSQL, media on object storage, static files, caching of rendered pages and menus, search engine friendly URLs, and a release process for template and plugin changes.

  • Deploy Saleor to Production

    Deploy the Saleor headless e-commerce platform, built on Django and GraphQL, to production: run the API container with PostgreSQL and Redis, configure Celery workers, media storage, secrets, allowed hosts and CORS for the dashboard and storefront, and run migrations on upgrade.

  • Build a Distroless Docker Image for Django

    Build a minimal, shell-less production image for Django using a multi-stage build with a Debian builder and a distroless or Chainguard Python runtime: copy the virtualenv, run as non-root, handle collectstatic and migrations without a shell, and debug safely.

  • Sign and Verify Django Docker Images With Cosign

    Sign Django container images with Sigstore Cosign in CI using keyless signing through GitHub Actions OIDC, attach SBOM and provenance attestations, and verify signatures before deploy or with a Kubernetes admission policy.

  • Deploy Django on Google Cloud Run

    If you want to deploy Django on Google Cloud Run, the basic path is straightforward: build a container and run it. The production-safe part is where most deployments fail.

  • Deploy Django on AWS ECS Fargate

    Run Django on AWS ECS Fargate with an ECR image, Secrets Manager credentials, an Application Load Balancer, one-off migration tasks, and safe rolling deploys.

  • Deploy Django with Kamal

    Deploy a Dockerized Django app with Kamal 2: deploy.yml, secrets, kamal-proxy HTTPS, a Postgres accessory, safe migrations, health checks, and rollbacks.

  • Deploy Django on Azure Container Apps

    Deploy a containerized Django app to Azure Container Apps with Azure Container Registry, PostgreSQL Flexible Server, secrets, a migration job, custom domains, and revisions.

  • Deploy Django with Coolify

    Deploy Django on your own server with Coolify: Dockerfile builds from Git, managed PostgreSQL and Redis, automatic HTTPS, environment variables, migrations, and backups.

  • Deploy Django with CapRover

    Deploy Django with CapRover: captain-definition, a Gunicorn Dockerfile, one-click PostgreSQL, container port and HTTPS settings, persistent media, and safe migrations.

  • Deploy Django with Docker Swarm

    Deploy Django with Docker Swarm: a stack file with replicas, Docker secrets, rolling start-first updates with automatic rollback, one-off migrations, and Nginx in front.

  • Deploy Django with Traefik and Docker

    Put Traefik in front of a Dockerized Django app: automatic Let's Encrypt certificates, HTTP to HTTPS redirects, Docker labels for routing, static files, and upload limits.

  • Preview Environments for Django Pull Requests

    Spin up a temporary Django environment for every pull request: GitHub Actions, Docker Compose on a preview host, wildcard subdomains, per-PR databases with seed data, and automatic teardown.

  • Deploy Django Docker Images from GitHub Container Registry

    Build Django images in GitHub Actions, push them to GHCR with immutable tags, pull them on servers with read-only credentials, deploy by tag or digest, and clean up old versions.

  • Self-Host Django Media Storage With MinIO

    Run MinIO as self-hosted S3-compatible storage for Django uploads: deploy it with Docker Compose or systemd, create a bucket and scoped user, configure django-storages, put MinIO behind Nginx with TLS, and back it up.

  • Create a Django Superuser in Production Without a Shell

    Create the first Django admin user in production non-interactively: createsuperuser --noinput with DJANGO_SUPERUSER_ environment variables, one-off containers and Jobs, PaaS consoles, an idempotent management command, and securing the account afterwards.

  • Kubernetes vs Docker Compose for Django

    Compare Kubernetes and Docker Compose for running Django in production: single-host simplicity versus multi-node scheduling, rolling updates, autoscaling, secrets, operational cost, and when a team should move from Compose to Kubernetes.

  • Deploy Django With Dokploy on Your Own Server

    Deploy Django with Dokploy, an open-source self-hosted PaaS: install it on a VPS, create an application from Git with a Dockerfile or Nixpacks, add PostgreSQL and Redis, configure domains with automatic HTTPS, run migrations, and schedule database backups.

  • Deploy Django With Easypanel

    Deploy Django with Easypanel, a Docker-based server control panel: create an app service from GitHub with a Dockerfile or buildpacks, add Postgres and Redis services, set environment variables, mount volumes for media, and enable HTTPS on a custom domain.

  • Deploy Django Behind Nginx Proxy Manager

    Put a Docker-based Django app behind Nginx Proxy Manager: create a proxy host with Let’s Encrypt, connect containers on a shared network, forward the right headers, serve static files, allow large uploads, and keep the admin UI private.

Run it well

Tuning, reliability, and operations once it works.

Check it

Review lists to run before launch or after a change.

  • Django Docker Production Checklist

    Review a Dockerized Django deployment before production: image build, non-root user, secrets, health checks, volumes, logging, resource limits, and release steps.

Fix it

Errors and symptoms, each traced to a cause and a fix.

Learning paths through this topic

Related topics