Oct 24, 2023 5 min read

How to Install Dokku on Ubuntu 20.04

Install Dokku on Ubuntu 20.04 with our step-by-step tutorial. It is a lightweight platform for easy app deployment and management.

Install Dokku on Ubuntu 20.04
Table of Contents

Choose a different version or distribution

Introduction

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

Dokku is a lightweight platform for easy app deployment and management. Similar to Heroku, Dokku provides an easy and cost-effective solution for deploying applications on Ubuntu 20.04 servers.

With Dokku, you can scale applications effortlessly, configure custom domains, integrate with version control systems like Git, and utilize various databases. Its active community and support make it an excellent choice for developers looking for a hassle-free, efficient deployment solution.

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

Advantages of Dokku

  1. Easy deployment: Dokku simplifies the process of deploying applications, allowing developers to easily deploy their code to a production environment with minimal effort.
  2. Minimal setup: With Dokku, there's no need to configure complex servers or infrastructure. It provides a lightweight platform that can be set up quickly and easily.
  3. Scalability: Dokku helps streamline the scaling process by allowing applications to be easily scaled up or down, ensuring they can handle increased traffic or demand as needed.
  4. Cost-effective: Being an open-source platform, Dokku eliminates the need for expensive commercial solutions, providing a cost-effective option for deploying and managing applications.
  5. Extensibility: Dokku offers a range of plugins and extensions, expanding its functionality and allowing developers to customize their deployment setup to meet their specific needs.

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 -NP . https://dokku.com/bootstrap.sh
sudo DOKKU_TAG=v0.30.7 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, add the ssh public key and other details using the following commands:

# Add Public key.
echo "$(cat ~/.ssh/id_rsa.pub)" | sudo dokku ssh-keys:add admin

# Set Domain/IP
dokku domains:set-global <domain_or_IP>

# Sample App
dokku apps:create test-app
💡
If you haven't generated your keys then use ssh-keygen command to generate it.
  • 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/IP-address.

cd ~/ruby-rails-sample
git remote add dokku dokku@<domain_or_IP>: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:

Example Success 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.

How can I scale my applications with Dokku?

Scaling applications with Dokku is straightforward. You can use the Dokku command line tool to easily scale your application horizontally by increasing the number of instances.

Is it possible to integrate Dokku with version control systems like Git?

Absolutely. Dokku seamlessly integrates with Git and deploys applications based on your Git repository. Simply push your code to the Dokku remote repository, and it will handle the deployment process.

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.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Tutorials - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.