Skip to content
Create a gist now

Instantly share code, notes, and snippets.

How to deploy Heroku-style on Digital Ocean with Dokku

Because a basic VPS at Digital Ocean costs $5 a month. And you can host as many apps as you want. An nginx serves as a proxy for your apps.


Now you don't have to install Dokku yourself anymore. There's a pre-configured Dokku image available on Digital Ocean, that you can spin up with just a few clicks...


  • Create a fresh Ubuntu 13.04 x64 VM. Use the desired domain as hostname

  • Set up the domain to point to the new VM's IP.

  • Set up a ~/.ssh/config for the key you want to use on the server.

    Host <host alias>
        User dokku
        PreferredAuthentications publickey,password
        IdentityFile /Users/<your username>/.ssh/id_rsa
        RequestTTY yes

    Now you don't have to type the user and full domain when pushing or specify which key to use (if you have multiple) in later ssh and git commands.

    You can't use RequestTTY in OpenSSH versions older than 5.8. (e.g. On MacOS < 10.9). You should instead execute ssh with the -t option.

  • Upload your public key for easy installation from the cloud.

    curl -s<your email>/<key identifier>/upload | bash

  • SSH into the VM.

    ssh root@<host alias> And enter the root pw.

    • Install your key.

      curl -s<your email>/<key identifier>/install | bash

    • Install Dokku.

      wget -qO- | sudo DOKKU_TAG=v0.2.1 bash

    • This also creates a user called dokku.
      Use su - dokku when logged in as root to drop down to normal privileges.

    • Make sure your domain is in /home/dokku/VHOST. Remove localhost entry if present.

    • Exit.
  • Set up the command to be executed when 'dokku' user connects with ssh (e.g.while pushing to the server.)

    cat ~/.ssh/ | ssh root@<host alias> "sudo sshcommand acl-add dokku <your username>"

    (username is not being used so far.)


  • Add the remote to your working copy.

    git remote add <remote name> <host alias>:app

    When pushing this will result in an app at You can force an different subdomain with git remote add deploy <host alias> (or none).

  • Deploy.

    git push <remote name> master

    Your app is uploaded and installed.
    To push a specific branch use git push <remote name> <branch name>:master

  • Control dokku

    You can execute dokku commands from your local shell.

    ssh <host alias> help

    Just replace help with the dokku command, e.g. to set environment variables:

    ssh <host alias> config:set <app> KEY1=VALUE1 [KEY2=VALUE2 …]

    The app is restarted with the new settings.
    The variables are stored in /home/dokku/xtc/ENV.

    You should execute ssh with the -t option if you don't have RequestTTY yes in your ssh config.



That wiki link hasn't existed in ages (if ever).

See here for our nginx docs.


Also this references an old version of dokku. Like several years old. We have more complete docs here and here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.