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.

Problem statement

You want the convenience of a PaaS, with Git-based deploys, one-click databases, domains with HTTPS, and a dashboard, but on your own VPS with a fixed monthly bill. Dokploy is an open-source, self-hosted platform built on Docker and Traefik that provides those features. Deploying Django on it is mostly a matter of giving it a good Dockerfile, wiring environment variables to its managed databases, and deciding where migrations run.

Django on DokployInstall Dokployon a VPSApplicationGit + DockerfileDatabasesPostgres, RedisDomainTraefik TLSDokploy builds containers from Git and routes them through Traefik with HTTPS.
  1. Install Dokploy on a fresh Ubuntu or Debian VPS with its install script and secure the dashboard with a domain and HTTPS.
  2. Create a project, add a PostgreSQL and a Redis database, and copy their internal connection URLs.
  3. Create an application from your Git repository using a Dockerfile (recommended) or Nixpacks.
  4. Set environment variables: DATABASE_URL, REDIS_URL, SECRET_KEY, ALLOWED_HOSTS, CSRF_TRUSTED_ORIGINS.
  5. Add a domain with Let's Encrypt, set the container port, and run migrations in the entrypoint or a deploy command.

Step-by-step solution

1. Install Dokploy

On a VPS with at least 2 GB of RAM:

curl -sSL https://dokploy.com/install.sh | sh

The script installs Docker, initializes Docker Swarm, and starts Dokploy and Traefik. Open the dashboard on port 3000, create the admin account, then assign a domain to the dashboard itself and close port 3000 in the firewall. Read the script before piping it to a shell on a production server.

2. Add databases

In a project, add a PostgreSQL database and a Redis database. Dokploy shows an internal connection URL, reachable from other services on the same Docker network, and optionally an external port. Use the internal URL for Django and keep external ports closed. Configure scheduled backups for PostgreSQL to an S3-compatible destination in the database's backup settings.

layers on the serverTraefikdomains, Let’s EncryptDjango applicationbuilt from GitCelery applicationsame repo, other commandPostgres and Redisinternal network, backupsDocker Swarminstalled by DokployEverything runs as containers that Dokploy managesdjango-deployment.com
The dashboard and the app share the server, so size it for both.

3. Create the application

Connect GitHub (or another Git provider) and select the repository and branch. Choose the build type:

  • Dockerfile: most predictable for Django; you control system packages, collectstatic, and the start command.
  • Nixpacks or buildpacks: detect Python automatically; set the start command to Gunicorn.

A minimal start command in the Dockerfile:

CMD ["sh", "-c", "python manage.py migrate --noinput && gunicorn config.wsgi --bind 0.0.0.0:8000 --workers 3"]

Running migrations in the start command is acceptable with a single replica. With several replicas, move migrations to a separate step so they run once.

4. Configure environment and domain

In the application's environment tab:

DJANGO_SETTINGS_MODULE=config.settings.production
SECRET_KEY=...
DATABASE_URL=postgresql://shop:...@shop-db-abc123:5432/shop
REDIS_URL=redis://default:...@shop-redis-def456:6379
ALLOWED_HOSTS=shop.example.com
CSRF_TRUSTED_ORIGINS=https://shop.example.com

Under Domains, add shop.example.com, set the container port (8000), and enable HTTPS with Let's Encrypt. Point the domain's DNS A record at the server. Set SECURE_PROXY_SSL_HEADER in Django, because Traefik terminates TLS.

5. Workers, logs, and redeploys

Create a second application from the same repository with the command celery -A config worker -l info and no domain. Enable automatic deploys on push, or trigger deploys from CI with Dokploy's webhook. Logs and container metrics are available per application in the dashboard.

Dokploy, Coolify, and CapRoverDokployCoolifyCapRoverOrchestrationDocker SwarmDockerDocker SwarmProxyTraefikTraefik or CaddyNginxBuild optionsDockerfile, NixpacksDockerfile, NixpacksDockerfile, captainDB backupsto S3to S3manualAll three host Django well; the differences are in toolingdjango-deployment.com
Feature sets change quickly; check current releases before choosing.

Explanation

Dokploy automates what you would otherwise script on a VPS: building images from Git, running them as Swarm services, connecting them on an overlay network, and configuring Traefik routes and certificates. Django sees an ordinary container environment: a port to listen on, environment variables for settings, and databases reachable by internal host names. You still own the server, so OS updates, firewall rules, disk space, and off-site backups are your responsibility.

Edge cases / notes

  • Resources. Builds run on the same server by default and can starve the running app of CPU and memory; consider building in CI and deploying images.
  • Media files. Container filesystems are replaced on deploy; mount a volume or use object storage for uploads.
  • Multiple servers. Dokploy can add remote servers and deploy to them, which separates the dashboard from production workloads.

Next steps

FAQ

Is Dokploy free?

The self-hosted version is open source. You pay for the server it runs on.

Should I use Nixpacks or a Dockerfile?

A Dockerfile is more predictable for Django, especially with system packages or custom build steps.

How do I run migrations with Dokploy?

In the container start command for a single replica, or as a separate command run once per deploy when you have several replicas.

Does Dokploy back up the database?

It can schedule PostgreSQL backups to S3-compatible storage. Configure and test them; they are not on by default.

Keep going