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
2. Create the environment file:
$ nano .env
DOKKU_HOSTNAME=dokku.example.com
DOKKU_VERSION=0.37.6
Deploy with Docker Compose
1. Add your user to the Docker group:
$ sudo usermod -aG docker $USER
$ newgrp docker
2. Create the Docker Compose manifest:
$ nano docker-compose.yml
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
3. Start the service:
$ docker compose up -d
$ docker compose ps
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
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
3. Add a Dokku entry to your SSH config:
$ nano ~/.ssh/config
Host dokku-server
HostName YOUR_SERVER_IP
User dokku
Port 3022
IdentityFile ~/.ssh/id_ed25519
Deploy a Sample App
1. Create the app on the server:
$ ssh dokku-server apps:create ruby-getting-started
$ ssh dokku-server apps:list
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
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
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
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
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
checksandprocfilehealth endpoints - Deploy multiple apps under subdomains by repeating the
apps:createflow
For the full guide with additional tips, visit the original article on Vultr Docs.
Top comments (0)