The Torture of “Manual Configuration”
Every time I start a new project, I feel a sense of dread. Spending time writing Dockerfiles, configuring Nginx Reverse Proxies, or fumbling with manual SSL Certbot setup takes up too much time. If you’ve ever used Heroku, you’re likely familiar with the “joy” of just typing git push heroku master and being done. However, Heroku’s current costs are not cheap. A basic dyno costs $7/month, and that figure escalates quickly if you need additional Database or Redis instances.
After six months of moving all my side projects to Dokku, I truly regret not knowing about it sooner. It saves me about 70% of environment setup time. Most importantly, I no longer encounter those silly errors caused by typos when manually configuring things on the server.
What is Dokku? Why Should You Use It?
Dokku is an open-source Heroku that runs directly on your server. It combines the power of Docker for containerizing applications and Nginx for traffic routing. The biggest selling point lies in Buildpacks. Dokku automatically detects if your application is Node.js, Python, or PHP to install the corresponding environment without you having to lift a finger.
In practice, on a 2GB RAM VPS (costing about $12/month), I have stably run 5 different applications. Running this many on Heroku could result in a monthly bill exceeding $50. Thanks to its smart container management mechanism, Dokku utilizes resources much better than installing each service individually the traditional way.
Prerequisites
To keep everything running smoothly, you will need:
- A VPS running Ubuntu 22.04 LTS (minimum 1GB RAM).
- A Domain with an A record pointed to your VPS IP.
- An SSH Key already set up on your local machine for security.
Step 1: Installing Dokku on your VPS
The Dokku development team has optimized the installation process into a single command line. Just SSH into your server and run the official bootstrap script:
# Download and run the latest stable installation script
wget -qO- https://dokku.com/install/v0.34.x/bootstrap.sh | sudo DOKKU_TAG=v0.34.x bash
This process usually takes 5 to 10 minutes. The script will automatically handle everything from Docker to necessary dependencies. You can take the opportunity to grab a cup of coffee while you wait.
Step 2: Configuring SSH Keys and Domain
Once installed, you need to grant your local machine permission to push code. Run the following command from your machine (not on the server):
# Push the public key to the server for identification
cat ~/.ssh/id_rsa.pub | ssh root@ip-server "dokku ssh-keys:add admin"
Next, set up the global domain. This is extremely important because Dokku will rely on this to automatically create subdomains for each of your applications later:
# Run this command directly on the server
dokku domains:set-global yourdomain.com
Step 3: Initializing the Application and Database
Suppose I’m developing a Node.js API called my-awesome-app. Instead of creating complex directories or Nginx configs, I just need a few lines of code:
# Create a new app
dokku apps:create my-awesome-app
# Install the Postgres plugin (only needs to be done once)
sudo dokku plugin:install https://github.com/dokku/dokku-postgres.git
# Create and link the database
dokku postgres:create my-db
dokku postgres:link my-db my-awesome-app
A major plus is that Dokku automatically injects the DATABASE_URL environment variable into the application. You don’t need to store database passwords in your code, which minimizes security risks.
Step 4: Deploying the App with Git Push
This is when you’ll feel your efforts have truly paid off. In your local code directory, add the remote and push the code:
git remote add dokku [email protected]:my-awesome-app
git push dokku master
The terminal screen will stream logs continuously: from running npm install to building the Docker image. Once finished, Dokku will provide a link like http://my-awesome-app.yourdomain.com for you to access immediately.
Step 5: Enabling Free SSL
Nowadays, a website without HTTPS is a major oversight. With Dokku, installing free SSL from Let’s Encrypt is a piece of cake. This plugin also features auto-renewal, allowing you to be completely hands-off.
# Install the Let's Encrypt plugin
sudo dokku plugin:install https://github.com/dokku/dokku-letsencrypt.git
# Configure email and enable
dokku config:set --no-restart my-awesome-app [email protected]
dokku letsencrypt:enable my-awesome-app
A Few “Hard-Won” Tips After 6 Months of Use
To operate Dokku stably in a production environment, I have a few small tips for you:
- Monitor Resources: Don’t forget to use the
dokku statscommand. It helps you know exactly which app is consuming the most RAM so you can plan a VPS upgrade in time. - Backup Strategy: Don’t be complacent with your data. I always use
dokku postgres:exportcombined with a cronjob to push backups to S3 every night. - Zero-downtime: Dokku supports zero-downtime deployment by default. It only shuts down the old container once the new container is ready to receive traffic, ensuring users don’t see 502 errors.
If you want a professional deployment workflow without the “headache” of Kubernetes, Dokku is the number one choice. It’s simple, effective, and extremely cost-efficient for small and medium projects.

