Skip to content

Instantly share code, notes, and snippets.

Last active May 12, 2022 14:38
Show Gist options
  • Save henrik/26bb73091712aa42abf2 to your computer and use it in GitHub Desktop.
Save henrik/26bb73091712aa42abf2 to your computer and use it in GitHub Desktop.
Notes from running Dokku on Digital Ocean.

My notes for Dokku on Digital Ocean.

These may be a bit outdated: Since I originally wrote them, I've reinstalled on a newer Dokku and may not have updated every section below.


Install dokku-cli (gem install dokku-cli) for a more Heroku-like CLI experience (dokku config:set FOO=bar).

# List/run commands when not on Dokku server (assuming a "henroku" ~/.ssh/config alias)
ssh henroku dokku
ssh henroku dokku config:get my-app

# Access the server, list commands, run command
ssh henroku
dokku config:get my-app

# See memory usage
# Source:
sudo docker stats $(sudo docker ps --format={{.Names}})
# With highest usage first, not live-updating
# Source:
sudo docker stats --no-stream --format "table {{.Name}}\t{{.Container}}\t{{.MemUsage}}" | sort -k 3 -h -r
# See server stats (memory, disk usage, load) - same as shown on login

# Interesting dirs
cd /var/lib/dokku/plugins  # plugins
cd ~dokku  # apps

Adding a new app

git remote add dokku  # Note to self: This might actually be "" these days.
git push dokku

ssh henroku dokku domains:add my-app  # and configure DNS

# DB?
ssh henroku dokku psql:create my-app

# memcache?
ssh henroku dokku memcached:create my-app  # MEMCACHE_SERVERS env will be set

Working with an app

# See logs
ssh henroku dokku logs my-app -t

# Conf
ssh henroku dokku config:get my-app
ssh henroku dokku config:set my-app KEY1=val KEY2=val

Removing a plugin

cd /var/lib/dokku/plugins
rm -rf the-plugin

# List containers, remove the ones from the plugin
ssh henroku
sudo docker ps -a
docker rm <the id>

# List images, remove the ones from the plugin
docker images
docker rmi <the id>


Use Digital Ocean's "Ubuntu with Dokku" image.

Create a swapfile to avoid out-of-memory errors during build/deploy (I got those sometimes even with a 1 GB RAM image):

ssh henroku
dd if=/dev/zero of=/swapfile bs=1024 count=1024000
mkswap /swapfile
swapon /swapfile

Change the default root password to avoid later issues with crontab not working:

sudo -u root passwd

Follow the instructions, specifying a new password as prompted, and store it in e.g. 1Password.


It's convenient to set up wildcard DNS so e.g. * points to this server.

With LoopiaDNS, you need to add a CNAME for sub-subdomain wildcards (e.g. * pointing to



This fork seems to be the most up to date, with nice features like autostart on server reboot.

cd /var/lib/dokku/plugins
git clone
git clone link  # dependency
dokku plugins-install


Before you install, see the section on getting a newer version of Postgres. At the time of writing, 9.4 has some cool new features over the default 9.3.

After install, run: dokku psql:start

(Got errors from Kloadut/dokku-pg-plugin, and it seems unmaintained.)

DB backups

Put one of these scripts (for dokku-postgres or for dokku-psql-single-container) in /root/, run chmod +x /root/

Then add something like this to crontab:

# m h  dom mon dow   command
  0 0  *   *   *     /root/

You will get daily backups in /var/backups/postgres. The script keeps a few days and then removes too old ones. Digital Ocean's infrequent server backups will include these dumps.

I recommend also adding a healthcheck to the cron job.

Static sites alongside Dokku

See this blog post.


Copy link

henrik commented Jan 20, 2020

For my own future reference:

If Dokku seems to get stuck with extra Docker processes like


(probably due to a half-completed deploy for some reason), this is the only thing I found to fix them:

  • ssh dokku ps:stop my-app
  • Check list of processes again, e.g. sudo docker stats --no-stream --format "table {{.Name}}\t{{.Container}}\t{{.MemUsage}}" | sort -k 3 -h -r
  • Kill the spare processes with sudo docker stop my-app.web.1.1557094771 and so on
  • Deploy the app (ps:start wasn't enough)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment