What Dokku Does
- Git Push Deploy: Push code, Dokku builds and deploys automatically
- Buildpacks: Auto-detect language and build (Node.js, Python, Ruby, Go, PHP, Java, etc.)
- Dockerfile: Deploy any Dockerfile-based application
- Docker Image: Deploy pre-built Docker images directly
- Automatic HTTPS: Let's Encrypt certificates provisioned and renewed automatically
- Zero Downtime: Zero-downtime deploys with health checks
- Scaling: Scale app processes horizontally
- Plugins: PostgreSQL, MySQL, Redis, MongoDB, RabbitMQ, and 100+ community plugins
- Domains: Custom domain management with automatic routing
- Environment Variables: Secure config management
Architecture
Developer
│
│ git push dokku main
│
┌───┴───────────────────────────────────┐
│ Dokku Server │
│ ┌─────────┐ ┌────────────────────┐ │
│ │ Git │──│ Builder │ │
│ │ Receive │ │ (Buildpack/Docker) │ │
│ └─────────┘ └────────┬───────────┘ │
│ │ │
│ ┌──────────────────────┴───────────┐ │
│ │ Docker Container (your app) │ │
│ └──────────────────────────────────┘ │
│ ┌──────────────────────────────────┐ │
│ │ Nginx (reverse proxy + SSL) │ │
│ └──────────────────────────────────┘ │
└───────────────────────────────────────┘Getting Started
1. Install Dokku
# On a fresh Ubuntu 22.04+ server
wget -NP . https://dokku.com/install/v0.34.8/bootstrap.sh
sudo DOKKU_TAG=v0.34.8 bash bootstrap.sh
# Set domain
dokku domains:set-global your-server.com
# Add your SSH key
echo "your-public-key" | dokku ssh-keys:add admin2. Create App
dokku apps:create my-node-app3. Add Database
# Install PostgreSQL plugin
dokku plugin:install https://github.com/dokku/dokku-postgres.git
# Create database and link to app
dokku postgres:create my-db
dokku postgres:link my-db my-node-app
# DATABASE_URL is automatically set in app environment4. Deploy
# On your local machine
git remote add dokku dokku@your-server.com:my-node-app
git push dokku main5. Enable HTTPS
dokku letsencrypt:enable my-node-app
# Auto-renews via cronCommon Commands
# App management
dokku apps:list # List all apps
dokku apps:create my-app # Create app
dokku apps:destroy my-app # Delete app
# Configuration
dokku config:set my-app KEY=value # Set env var
dokku config:show my-app # Show all env vars
# Domains & SSL
dokku domains:add my-app example.com # Add custom domain
dokku letsencrypt:enable my-app # Enable HTTPS
# Scaling
dokku ps:scale my-app web=3 worker=2 # Scale processes
# Databases (plugins)
dokku postgres:create db1 # Create PostgreSQL
dokku redis:create cache1 # Create Redis
dokku postgres:link db1 my-app # Link to app
# Logs & debugging
dokku logs my-app -t # Tail logs
dokku enter my-app web # Shell into container
dokku run my-app npm run migrate # Run one-off commandSupported Languages
| Language | Detection | Build Method |
|---|---|---|
| Node.js | package.json | Buildpack |
| Python | requirements.txt / Pipfile | Buildpack |
| Ruby | Gemfile | Buildpack |
| Go | go.mod | Buildpack |
| PHP | composer.json | Buildpack |
| Java | pom.xml / build.gradle | Buildpack |
| Static | index.html | Buildpack (nginx) |
| Any | Dockerfile | Docker build |
Dokku vs Alternatives
| Feature | Dokku | Heroku | CapRover | Coolify |
|---|---|---|---|---|
| Open Source | Yes (MIT) | No | Yes | Yes |
| Git push deploy | Yes | Yes | Yes | Yes |
| Auto HTTPS | Let's Encrypt | Built-in | Let's Encrypt | Let's Encrypt |
| Buildpacks | Heroku compatible | Native | Dockerfile | Nixpacks |
| Database plugins | Official | Add-ons | One-click apps | One-click |
| Multi-server | Via plugins | Built-in | Docker Swarm | Yes |
| Pricing | Free (VPS cost) | $5+/dyno/mo | Free (VPS cost) | Free (VPS cost) |
| Best for | Single server | SaaS | Web UI fans | Modern UI fans |
常见问题
Q: Dokku 和 CapRover 怎么选? A: Dokku 更贴近 Heroku 体验,命令行操作为主,buildpack 生态成熟。CapRover 有漂亮的 Web UI,更适合不习惯命令行的用户。功能上两者相当,个人偏好决定。
Q: 一台服务器能跑多少个应用? A: 取决于应用资源消耗。一台 4GB RAM 的 VPS 通常可以跑 5-10 个小型 Web 应用(Node.js/Python)+ 对应数据库。建议每个应用设置内存限制。
Q: 支持多服务器集群吗? A: Dokku 默认是单服务器架构。通过 dokku-scheduler-k3s 插件可以扩展到 K3s 集群。对于多服务器需求,也可以考虑 Coolify 或 CapRover。
来源与致谢
- GitHub: dokku/dokku — 31.9K+ ⭐ | MIT
- 官网: dokku.com