How to Install Dokku on Ubuntu 18.04

Choose a different version or distribution

Introduction

Before we begin talking about how to install Dokku on Ubuntu 18.04 OS, let’s briefly understand – What is Dokku?

Dokku is an extensible, open-source service platform that can run on a single server of your choice. With Dokku Ubuntu, you can set up your own PaaS easily. It allows developers to easily deploy and manage web applications.

You will install, configure, and test Dokku on Ubuntu in this tutorial. Also, we will answer some FAQs regarding the Dokku installation.

Prerequisites

Major Benefits of Dokku

  1. Simplicity: Dokku is very easy to install and use. It requires minimal configuration, making it ideal for developers who want to quickly deploy and manage web applications.
  2. Flexibility: Dokku supports a wide range of web technologies and programming languages, from Ruby on Rails to Python and Node.js. This means that teams can use it for almost any type of application.
  3. Cost-effectiveness: Dokku is open-source and can be installed on a variety of computing platforms, including cloud services. This makes it a cost-effective alternative to other PaaS tools.
  4. Saves Development Time: Dokku automates many of the DevOps tasks associated with deploying and managing web applications. This allows developers to focus on writing code instead of worrying about infrastructure, saving them valuable development time.
  5. Scalability: Dokku makes it easy to scale web applications up or down, depending on the traffic and resource requirements. This is done automatically, so developers don't need to worry about manually configuring servers or load balancers.

Step 1 – How to Install Dokku on Ubuntu

1) At first, Set your Domain name's server hostname to subdomain.

Example: dokku.example.com

2) Now, configure your DNS towards your subdomain with a wild card to the Public IP of your Dokku Server.

3) Make sure to add SSH keys to your server at deployment for a secured login process.

4) After that, run the installation bootstrap script with a similar version number using the commands below.

wget https://dokku.com/install/v0.29.4/bootstrap.sh
sudo DOKKU_TAG=v0.29.4 bash bootstrap.sh

Within a couple of minutes, the script automatically installs the required assets including Docker Engine, Herokuish, and Dokku Ubuntu itself.

Step 2 – Configure the basic settings

1) After the installation, configure the temporary web page on your Dokku server. Then, finalize the installation by browsing your server's domain name or IP address.

You might not see a web interface like the above. then you have to manually add the ssh public key and other details using the following commands:

# Public key
echo "your-public-key-contents-here" | dokku ssh-keys:add admin

# Domain name
dokku domains:set-global dokku.me

# App
dokku apps:create test-app
  • SSH key added at the time of server deployment will be shown in the Public Key list for Admin Access.
  • Now, the Dokku user account which manages the application includes the Keys in this list.

2) After that, set your domain name as the Hostname while deploying your server. Use the default DNS name in case you don't have a domain name.

3) Finally, after DNS configuration, you might choose to enable the virtual host naming for apps. This option enables Dokku to make installed services accessible through <app-name>.dokku.exapmle.com subdomains. Configure a wildcard A record for your domain to allow access to the application subdomains.

A   *.dokku.example.com   <publi IP address>

4) Now, complete the setup process by clicking the Finish Setup button at the bottom of the page.

Now, your Dokku Ubuntu platform is installed and ready to deploy your applications.

Step 3 – Test the Platform

1) Firstly, get ready with your GitHub account.

  • Sign up for GitHub if you are not having an account already and then include an SSH Key to your account for secure login from your local system.

2) Using the below command creates a new application on your Dokku server.

dokku apps:create ruby-rails-sample

3) After that, install the Postgres plugin (required by an app) using the below command.

sudo dokku plugin:install https://github.com/dokku/dokku-postgres.git

4) Now, create a new database for the app.

dokku postgres:create rails-database

5) Now, use the command below so that the sample app can access the database reserved for it.

dokku postgres:link rails-database ruby-rails-sample

6) After that, download the sample app from GitHub on your local computer. To get Git installed, follow the instruction on the git download page. The commands below are to be run only on a Linux System.

git clone https://github.com/JetBrains/sample_rails_app.git ~/ruby-rails-sample

7) Now, by using the below command, add a new remote location for Git pointing towards your Dokku server by adding an application name at the end of the domain name.

  • Example: <doku.exapmle.com> (Add your domain name in the place of the example).
cd ~/ruby-rails-sample
git remote add dokku dokku@<dokku.example.com>:ruby-rails-sample

8) Lastly, deploy the application onto the Dokku server by using the below command.

git push dokku master

Congratulations! You have successfully deployed your app on the Dokku server when you get a similar hello page:

FAQs to Install Dokku on Ubuntu

Do I need to install any dependencies before installing Dokku?

No, the Dokku installer will install any necessary dependencies automatically.

Is there a graphical interface for managing Dokku?

Yes, Dokku comes with a web dashboard that can be accessed by entering your server’s IP address in your web browser.

Can I install Dokku on a local machine instead of a server?

Yes, you can install Dokku on your local machine if it runs Ubuntu. However, this is mainly meant for development purposes.

Is Dokku easy to uninstall if I change my mind?

Yes, Dokku can be uninstalled by running a single command: sudo dokku uninstall

Is there a way to upgrade Dokku to a newer version?

Yes, you can upgrade Dokku using the command sudo dokku upgrade. However, it’s recommended to always backup your Dokku configuration before upgrading.

Conclusion

We hope this tutorial helped you understand how to install Dokku on your Ubuntu machine. To learn more about the Dokku installation for Ubuntu, check out the official Dokku install documentation.

If you have any queries, please leave a comment below, and we’ll be happy to respond to them for sure.