Choose a different version or distribution
Introduction
Before we begin talking about how to install Dokku on Ubuntu 22.04 OS, let’s briefly understand – What is Dokku?
Dokku is an open-source platform that simplifies the deployment and management of web applications. It offers a Heroku-like experience by leveraging Docker and Git to automate the deployment process. With Dokku, developers can quickly deploy their applications to a cloud server, eliminating the need for complex configuration and setup.
It supports various programming languages and frameworks, making it a versatile solution for developers. Dokku's simplicity and flexibility make it an ideal choice for small to medium-sized projects, enabling developers to focus on building their applications without worrying about infrastructure management.
You will install, configure, and test Dokku on Ubuntu 22.04 in this tutorial. We will also address a few FAQs on how to install Dokku on Ubuntu 22.04.
Advantages of Dokku
- 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.
- 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.
- 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.
- 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.
- 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.
Prerequisites to Install Dokku on Ubuntu 22.04
- Ubuntu 22.04 64-bit operating system
- Server with minimum RAM of 2GB
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
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:
FAQs to Install Dokku on Ubuntu 22.04
Can I install Dokku on other Linux distributions?
Yes, Dokku supports various Linux distributions, including Ubuntu, Debian, and CentOS.
Does Dokku require Docker?
Yes, Dokku relies on Docker to create and manage containers for deploying applications.
Can I use Dokku to deploy applications written in different programming languages?
Yes, Dokku supports multiple programming languages and frameworks, making it versatile for various development needs.
Is Dokku suitable for small-scale projects only?
No, Dokku is scalable and can handle both small and medium-sized projects with ease.
Can I use Dokku to deploy my existing application?
Yes, Dokku allows you to deploy existing applications by linking them to a Git repository.
Does Dokku provide a web-based interface?
Yes, Dokku includes a web interface that allows you to manage your applications and configurations.
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.