獨家架構與決策對照表
深度解構 Heroku 與 Dokku 在資料架構、運維開銷與授權風險上的核心指標差異。
The fundamental difference between the two platforms lies in hosting control and management overhead: Heroku is a fully managed, proprietary cloud PaaS, whereas Dokku is an open-source, self-hosted PaaS that runs on your own hardware using Docker. While Heroku charges premium rates per dyno and database instance to completely abstract away server administration, Dokku delivers an identical “git push” deployment experience on cheap VPS instances for the price of raw compute. Ultimately, migrating to Dokku eliminates Heroku’s compounding monthly costs but trades it for the responsibility of maintaining your own single-server Linux infrastructure.
10-Dimension Comparison
| Dimension | Heroku | Dokku |
|---|---|---|
| Pricing | Proprietary tiers from $5/mo (Eco) to $25+/mo (Standard). Costs scale steeply per dyno and add-on. | Free and open-source (MIT License). You only pay for your underlying VPS or bare-metal server. |
| Self-Hosting | No. Fully proprietary cloud platform managed exclusively by Salesforce. | Yes. Designed natively for self-hosting on any Linux-based server (Ubuntu, Debian, etc.). |
| API Support | Rich, well-documented platform API for programmatic deployment and configuration. | Extensible command-line interface with API-like control via SSH and community HTTP API plugins. |
| Integration Count | Hundreds of pre-configured, one-click marketplace Add-ons (Databases, monitoring, logging). | Hundreds of community plugins, plus native access to any standard Docker image on Docker Hub. |
| Learning Curve | Extremely low. Zero server administration knowledge required. | Moderate. Requires basic SSH, Linux system administration, and Docker understanding. |
| Community Support | Large, mature developer community, though official focus has shifted toward enterprise. | Active, passionate open-source community on GitHub, Discord, and Reddit. |
| Security | Highly secure out of the box; ISO, SOC, and PCI compliance options available (Enterprise). | Self-managed. Security depends on your VPS firewall, SSH keys, and OS patching diligence. |
| Scalability | Easy horizontal scaling via a slider; limited by dyno memory constraints. | Limited to single-server vertical scaling by default; multi-server setups require migration to Kubernetes. |
| UI Usability | Outstanding, polished web dashboard for monitoring, metrics, and configuration. | CLI-first interface by default; third-party web UIs exist but require manual setup. |
| Support | Tiered ticketing support; premium 24/7 support plans available for enterprise customers. | Community-driven via GitHub issues and chat channels; no official SLA-backed support. |
Heroku Overview
Heroku, owned by Salesforce, is the pioneer of the Platform-as-a-Service (PaaS) paradigm, renowned for its developer-centric “git push heroku master” workflow. By abstracting away server provisioning, OS patching, and network configuration, Heroku allows developers to focus entirely on writing application code. Its ecosystem relies on “dynos”—isolated Linux containers—and features an extensive marketplace of pre-configured third-party add-ons for databases, logging, and monitoring.
In 2026, Heroku remains highly popular for rapid prototyping and enterprise deployments that require zero operational overhead. However, since the retirement of its free tier, Heroku has become increasingly cost-prohibitive for scaling applications. Pricing starts at $5/month for the Eco tier (which sleeps after inactivity) and climbs to $7/month for Basic and $25/month for Standard Production dynos. Crucially, as resource demands grow, scaling horizontally or adding managed databases (starting at $5/month for Postgres and $3/month for Redis) rapidly balloons monthly expenses. This financial steepness, combined with a highly opinionated platform design that restricts low-level OS customization, makes Heroku a premium luxury that many resource-conscious organizations find difficult to justify once their applications mature beyond the initial launch phases.
Dokku Overview
Dokku is an open-source, self-hosted Platform-as-a-Service (PaaS) written in Go and Bash that leverages Docker to manage the lifecycle of applications. Often described as a “personal Heroku,” Dokku replicates the premium PaaS developer experience on your own infrastructure, allowing you to deploy applications with a simple git push to a cheap virtual private server (VPS). Licensed under the permissive MIT license, Dokku works by installing Docker on a single host and using Heroku-compatible buildpacks (via Cloud Native Buildpacks) or native Dockerfiles to build container images.
Once configured, Dokku provisions containers, configures Nginx or Traefik reverse proxies, and manages SSL certificates via Let’s Encrypt automatically. While it lacks the native multi-server clustering found in Kubernetes, Dokku offers an incredibly high overlap score (9/10) with Heroku’s command-line interface and deployment philosophies. This design makes it an ideal cost-saving alternative for developers, agencies, and small startups. By transitioning to Dokku, teams gain absolute control over their underlying operating system, disk space, and memory. This freedom eliminates arbitrary platform restrictions and lets them leverage cheap raw compute from providers like DigitalOcean, Linode, or AWS, completely side-stepping Heroku’s vendor lock-in and scaling markups.
Core Feature Comparison
1. Deployment & Build Workflow
- Heroku: Uses a Git-driven Git-receive hook. When you run
git push heroku main, Heroku’s proprietary build system detects your language, applies the appropriate Heroku Buildpack, compiles your assets, and deploys the slug to a run-ready dyno. While incredibly reliable, you are locked into Heroku’s build limits (such as a 15-minute timeout limit and a maximum slug size of 500MB). - Dokku: Offers identical Git-push-to-deploy capabilities (
git push dokku main). However, Dokku is significantly more flexible under the hood. It supports both Cloud Native Buildpacks (CNBs)—which are modern, Heroku-compatible builders—and nativeDockerfiles. If your repository contains aDockerfile, Dokku will bypass buildpacks entirely and build your custom image directly on the host. This means you have no arbitrary compile time limits or package payload restrictions, allowing you to deploy complex machine learning runtimes or custom compiled C-bindings with ease.
2. Database & Integration Ecosystem
- Heroku: Offers the legendary Heroku Add-on Marketplace. With a single click or command, you can provision fully managed Postgres, Redis, Elasticsearch, and Memcached instances. These are run on separate, managed infrastructure with automated backups, point-in-time recovery, and high availability. The trade-off is price; these managed services carry a heavy markup.
- Dokku: Employs a robust CLI-based plugin system to achieve parity. By running commands like
dokku postgres:create my-db, Dokku pulls the official PostgreSQL Docker image, provisions an isolated container, links it to your application, and configures the environment variables. There are official, highly stable plugins for Redis, MariaDB, MongoDB, Memcached, and Elasticsearch. While this gives you unlimited, free databases, you are sharing the resource pool (RAM/CPU/Disk) of your single host. You must also manage your own database backups, which can be easily automated using the plugin’s built-in S3 export commands.
3. Infrastructure Control & Customization
- Heroku: Operates on an ephemeral filesystem. Any files written directly to the disk of a running dyno disappear whenever the dyno restarts (which happens at least once every 24 hours). You cannot access root privileges (
sudo), install custom Ubuntu APT packages on the fly, or mount persistent storage volumes directly. You are forced to offload files to cloud object storage like AWS S3. - Dokku: Runs on standard Linux virtual machines, giving you absolute root access over the host. If your application requires persistent local storage (for uploads, SQLite databases, or local caches), you can use Dokku’s storage mounting system (
dokku storage:mount my-app /var/lib/my-app:/app/uploads). This maps a folder on your host machine directly inside the container, completely bypassing the limitations of an ephemeral filesystem while retaining isolated container security.
Pricing Comparison & Cost Scaling
To understand how pricing diverges, let’s look at a typical production stack scaling from a single web app to a multi-service setup.
The Stack Profile:
- Web App: Requires 1 GB of RAM.
- Background Worker: Requires 512 MB of RAM.
- Database: PostgreSQL (with a minimum of 10 GB storage).
- Caching/Session store: Redis.
Scenario 1: Basic Production Setup
- Heroku Monthly Cost:
- Web Dyno (Standard 2X - 1GB RAM): $50
- Worker Dyno (Standard 1X - 512MB RAM): $25
- Heroku Postgres (Premium-0 - 4GB RAM, High Availability): $50
- Heroku Data for Redis (Premium-0 - 1.5GB RAM): $30
- Total Heroku Monthly Bill: $155/month
- Dokku Monthly Cost:
- DigitalOcean or Hetzner VPS (2 vCPUs, 4GB RAM, 80GB SSD storage): $24
- Dokku Software License: $0 (Free/Open Source)
- Postgres Container: $0 (Runs on the VPS, shares RAM)
- Redis Container: $0 (Runs on the VPS, shares RAM)
- Total Dokku Monthly Bill: $24/month
Scenario 2: Scaling Up (5 Web Apps, 5 Databases, 3 Background Workers)
- Heroku Monthly Cost:
- 5x Standard 2X Dynos: $250
- 3x Standard 1X Workers: $75
- 5x Premium-0 Postgres DBs: $250
- 3x Redis Instances: $90
- Total Heroku Monthly Bill: $665/month
- Dokku Monthly Cost:
- Larger VPS Instance (4 vCPUs, 16GB RAM, 160GB NVMe storage): $80
- Dokku Software License: $0
- Databases, Workers, and Redis instances run as isolated Docker containers on the same host: $0
- Total Dokku Monthly Bill: $80/month
By migrating to Dokku, teams can easily cut their hosting expenses by 80% to 90%, as they are only paying for the raw hardware resources rather than a markup per service container.
Who Should Choose Heroku?
Scenario 1: Organizations with Zero DevOps or Sysadmin Staff
If your engineering team consists strictly of front-end and back-end developers with no desire to learn Linux administration, SSH keys, firewall rules, or Docker volumes, Heroku is the logical choice. The peace of mind that comes from knowing Salesforce engineers manage OS patches and security updates 24/7 is worth the premium.
Scenario 2: Enterprises Requiring Hardened Compliance (SOC2, HIPAA, PCI)
For applications handling highly regulated medical, financial, or governmental data, Heroku’s Private Spaces and Enterprise shields provide turnkey compliance pathways. Configuring a self-hosted Dokku server to meet strict HIPAA or PCI compliance standards requires extensive manual hardening, external audits, and continuous network vigilance.
Scenario 3: Rapid Prototyping and Ultra-Fast MVPs
When validating a product hypothesis where time-to-market is measured in days, Heroku’s speed remains unmatched. You can launch a fully functional web app, a staging environment, and a managed database in less than ten minutes without provisioning a single VPS or configuring domain names.
Who Should Choose Dokku?
Scenario 1: Bootstrapped Startups and Indie Hackers on a Budget
If you are running multiple side projects, pre-revenue SaaS apps, or staging environments, Heroku’s pricing model will quickly drain your runway. Dokku allows you to run dozens of low-traffic node, python, or rails apps on a single $10/month server, maximizing your operational margins.
Scenario 2: Legacy Apps Needing System Packages and Custom Disk Access
Applications that rely on system-level dependencies (like ffmpeg, specific fonts, PDF generation engines, or legacy C binaries) are incredibly painful to run on Heroku’s restricted runtime. On Dokku, you can modify the Dockerfile to install any Ubuntu package with apt-get or mount a persistent directory directly onto your host disk.
Scenario 3: Software Agencies Managing Client Portfolios
Agencies hosting 30+ low-to-medium traffic client portfolios can spin up a dedicated 8GB or 16GB RAM VPS, run Dokku, and host all client websites in isolated containers. This strategy consolidates infrastructure management, drastically reduces billing complexity, and allows agencies to pocket the margin difference.
Migration Assessment: Heroku to Dokku
Migrating an application from Heroku to Dokku is a highly streamlined process because Dokku was explicitly engineered to emulate Heroku’s behavior. Developers familiar with modern AI-driven coding engines like Claude 4.8 Sonnet or GPT-5.5 will find that drafting Dokku deployment scripts and shell commands is incredibly quick and reliable.
1. File Structure & Configuration
- The Procfile: Dokku respects your Heroku
Procfilewithout modification. If your Procfile definesweb: npm startandworker: python worker.py, Dokku will automatically spin up two separate Docker containers—one for the web server and one for your worker process. - Environment Variables: Dokku uses a nearly identical syntax for managing environment variables.
- Heroku:
heroku config:set DATABASE_URL=mongodb://... -a my-app - Dokku:
dokku config:set my-app DATABASE_URL=mongodb://...
- Heroku:
2. Buildpacks vs. Dockerfiles
If your Heroku app uses standard language buildpacks (e.g., Ruby, Node.js, Python, Go, PHP, Java), Dokku will automatically identify the stack using its built-in Cloud Native Buildpack integration. No code alterations are required. If you use a custom multi-buildpack setup on Heroku, it is highly recommended to write a basic Dockerfile instead. This simplifies your build pipeline and ensures absolute reproducibility on your Dokku server.
3. Database Migration
To migrate your data from Heroku Postgres to Dokku:
- Put your Heroku app into maintenance mode:
heroku maintenance:on - Generate a Heroku database backup:
heroku pg:backups:capture - Download the dump file:
heroku pg:backups:download - Spin up your Dokku Postgres instance:
dokku postgres:create prod-db - Import the dump file directly into your Dokku database container:
4. Ephemeral vs. Persistent File Systems
Before migrating, verify if your app writes files to disk. If your Heroku app was built correctly following the “Twelve-Factor App” methodology, it likely uploads files to an external storage service like AWS S3. If it does, no changes are needed. If it writes to local disk, you must utilize Dokku’s storage mount commands (dokku storage:mount) to map a folder on your host VPS to your application’s folder structure.
Final Verdict
The choice between Heroku and Dokku boils down to a classic engineering trade-off: convenience vs. control (and cost).
Heroku remains the premier choice for organizations that treat infrastructure as a pure distraction. If you have the budget to support its premium pricing tiers, Heroku frees your development team from the minutiae of server administration, offering unparalleled ease of scale and robust enterprise support.
Dokku, on the other hand, is the ultimate developer-empowerment tool. It successfully democratizes the PaaS experience, giving you the elite “git push” developer workflow without the commercial premium. If you possess basic Linux skills and want to host your software on your own terms, Dokku is an incredibly stable, performant, and cost-effective alternative that can run hundreds of applications for a fraction of the cost of Heroku.
Data verified as of 2026-06-25. Please check the official pages of Heroku and Dokku for live pricing.