DEV Community

Cover image for Deploying Dokku Lightweight Open-Source PaaS on Ubuntu 24.04
Sanskriti Harmukh for Vultr

Posted on with Aashish Chaurasiya • Originally published at docs.vultr.com

Deploying Dokku Lightweight Open-Source PaaS on Ubuntu 24.04

Dokku is an open-source, Heroku-like Platform-as-a-Service that lets you git push apps and have them built and deployed automatically. This guide deploys Dokku on Ubuntu 24.04 with Docker Compose, registers an SSH key, deploys a sample Ruby app, and switches the proxy to Traefik for automatic HTTPS. By the end, you'll have a Dokku PaaS running an app at your domain over HTTPS.


Set Up the Directory Structure

1. Create the project directory:

$ mkdir -p ~/dokku/data
$ cd ~/dokku
Enter fullscreen mode Exit fullscreen mode

2. Create the environment file:

$ nano .env
Enter fullscreen mode Exit fullscreen mode
DOKKU_HOSTNAME=dokku.example.com
DOKKU_VERSION=0.37.6
Enter fullscreen mode Exit fullscreen mode

Deploy with Docker Compose

1. Add your user to the Docker group:

$ sudo usermod -aG docker $USER
$ newgrp docker
Enter fullscreen mode Exit fullscreen mode

2. Create the Docker Compose manifest:

$ nano docker-compose.yml
Enter fullscreen mode Exit fullscreen mode
services:
  dokku:
    image: dokku/dokku:${DOKKU_VERSION}
    container_name: dokku
    network_mode: bridge
    ports:
      - "3022:22"
    volumes:
      - "./data:/mnt/dokku"
      - "/var/run/docker.sock:/var/run/docker.sock"
    environment:
      DOKKU_HOSTNAME: ${DOKKU_HOSTNAME}
      DOKKU_HOST_ROOT: /var/lib/dokku/home/dokku
      DOKKU_LIB_HOST_ROOT: /var/lib/dokku/var/lib/dokku
    restart: unless-stopped
Enter fullscreen mode Exit fullscreen mode

3. Start the service:

$ docker compose up -d
$ docker compose ps
Enter fullscreen mode Exit fullscreen mode

Register an SSH Key

1. Generate a key on your workstation:

$ ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -C "dokku"
$ cat ~/.ssh/id_ed25519.pub
Enter fullscreen mode Exit fullscreen mode

2. Register the public key with Dokku:

$ echo "YOUR_SSH_KEY" | docker compose exec -T dokku dokku ssh-keys:add admin
$ docker compose exec -it dokku dokku ssh-keys:list
Enter fullscreen mode Exit fullscreen mode

3. Add a Dokku entry to your SSH config:

$ nano ~/.ssh/config
Enter fullscreen mode Exit fullscreen mode
Host dokku-server
  HostName YOUR_SERVER_IP
  User dokku
  Port 3022
  IdentityFile ~/.ssh/id_ed25519
Enter fullscreen mode Exit fullscreen mode

Deploy a Sample App

1. Create the app on the server:

$ ssh dokku-server apps:create ruby-getting-started
$ ssh dokku-server apps:list
Enter fullscreen mode Exit fullscreen mode

2. Clone the sample app locally and push it:

$ git clone https://github.com/heroku/ruby-getting-started
$ cd ruby-getting-started
$ git remote add dokku dokku-server:ruby-getting-started
$ git push dokku main
Enter fullscreen mode Exit fullscreen mode

Switch to Traefik with Let's Encrypt

1. Stop the default Nginx proxy and enable Traefik:

$ ssh dokku-server nginx:stop
$ ssh dokku-server proxy:set --global traefik
$ ssh dokku-server traefik:set --global letsencrypt-email username@example.com
Enter fullscreen mode Exit fullscreen mode

2. Assign the domain and start Traefik:

$ ssh dokku-server domains:set ruby-getting-started dokku.example.com
$ ssh dokku-server traefik:start
$ ssh dokku-server ps:rebuild ruby-getting-started
Enter fullscreen mode Exit fullscreen mode

Open https://dokku.example.com to confirm the app is served over HTTPS.


Manage Environment Variables

$ ssh dokku-server config:set ruby-getting-started SECRET_KEY=your-secret-value
$ ssh dokku-server config:set ruby-getting-started DB_HOST=localhost DB_USER=admin DB_PASS=secret
$ ssh dokku-server config:show ruby-getting-started
$ ssh dokku-server config:unset ruby-getting-started SECRET_KEY
Enter fullscreen mode Exit fullscreen mode

Next Steps

Dokku is running with an app deployed via git push and Traefik handling HTTPS. From here you can:

  • Install plugins for PostgreSQL, MySQL, Redis, and other backing services
  • Configure zero-downtime deploys with checks and procfile health endpoints
  • Deploy multiple apps under subdomains by repeating the apps:create flow

For the full guide with additional tips, visit the original article on Vultr Docs.

Top comments (0)