Dokku is a robust platform-as-a-service (PaaS) solution designed to streamline the software deployment process for developers. This introduction will guide you on how to install Dokku on Ubuntu 22.04 Jammy Jellyfish or its older stable release of Ubuntu 20.04 Focal Fossa, highlighting its key features and benefits.
Key Features of Dokku:
- Heroku-Inspired Design: With a user-friendly interface similar to Heroku, Dokku provides ease of deployment without the limitations of a shared platform.
- Cost-Effective: When paired with a cloud provider, Dokku is an economical alternative to other PaaS solutions, optimizing your resources effectively.
- Customization Freedom: Dokku allows developers to tailor the hosting environment to meet various deployment requirements.
- Plugin Variety: A wide range of community-driven plugins enhances Dokku’s functionality, offering features from database integrations to certificate management.
- Scalability: Designed with scalability in mind, Dokku supports horizontal container scaling and is compatible with various cloud providers to adapt to the needs of growing applications.
Dokku simplifies deployment, allowing developers to push applications via git into a Docker container, ensuring scalability and consistency across different environments. Whether you are a solo developer, hobbyist, or part of a team, Dokku offers a blend of efficiency, adaptability, and simplicity for your deployment needs. The upcoming guide will walk you through the steps to install Dokku on Ubuntu 22.04 Jammy Jellyfish or 20.04 Focal Fossa, paving the way for a smoother deployment experience.
Before proceeding, ensure that the Docker Compose Plugin is installed on your Ubuntu system. If you haven’t done so, please refer to our guide on Installing Docker on Ubuntu.
Table of Contents
Install Dokku on Ubuntu 22.04 or 20.04
The following sections provide a step-by-step guide on how to install Dokku on Ubuntu Linux. Dokku is a powerful and flexible Platform as a Service (PaaS) that runs on your servers, allowing you to deploy and manage applications with the ease and speed of modern cloud providers. This guide will facilitate the entire process, from initial system updates to the confirmation of successful Dokku installation.
Step 1: Updating Ubuntu Before Dokku Installation
Our first task is to ensure our Ubuntu system is up-to-date. Updating system packages keeps our environment secure and avoids conflicts with new software installations. We achieve this by executing the following commands:
sudo apt update
sudo apt upgrade
These commands update the list of available packages and their versions (apt update) and then upgrade the installed packages to their latest versions (apt upgrade).
Step 2: Install Initial Packages for Dokku on Ubuntu
Before you install Dokku, ensure your system already has Docker installed. If not, consult our guide on Docker installation for Ubuntu Linux. With Docker operational, install the essential Docker Compose plugin by executing the following command:
sudo apt install docker-compose-plugin -y
Next, we need to install a set of required packages. These are vital for the successful installation of Dokku and include utilities for managing software and security certificates, among other things. To install these packages, we use the following command:
sudo apt install ca-certificates curl lsb-release dirmngr software-properties-common apt-transport-https -y
This command instructs the package manager to install the specified packages, and the
-y flag allows the process to proceed without requiring confirmation at each step.
Step 3: Import Dokku APT Repository on Ubuntu 22.04 or 20.04
To ensure we’re installing the official version of Dokku, we must import its APT repository. This is a two-step process that involves first importing the GPG key and then the repository itself.
To import the GPG key, use the following command:
curl -fSsL https://packagecloud.io/dokku/dokku/gpgkey | gpg --dearmor | sudo tee /usr/share/keyrings/dokku.gpg > /dev/null
The command fetches the GPG key from the specified URL, de-armors it (i.e., converts it into binary format), and then writes it to a specific file in your system’s keyring directory.
To import the repository, use the subsequent command:
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/dokku.gpg] https://packagecloud.io/dokku/dokku/ubuntu $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/dokku.list
This command adds the Dokku repository to your APT sources list. The architecture and signing key are specified as parameters for added security.
Step 4: Refreshing the APT Cache After Docker PPA Import on Ubuntu
With the Dokku repository added, we must refresh our APT cache. This action will inform APT of the packages in the Dokku repository. Use the following command to update the APT cache:
sudo apt update
Step 5: Install Dokku on Ubuntu 22.04 or 20.04 via APT Command
After preparing our system, we can install Dokku on Ubuntu 22.04 or 20.04. Start the straightforward installation with the following command:
sudo apt install dokku
The Dokku installation process is more than just a simple package installation; it’s the foundational step in setting up a Platform as a Service (PaaS) on your server. As such, it includes a series of prompts allowing customization based on your unique project needs and server environment.
Enabling the Nginx Vhosts Plugin with Dokku on Ubuntu
During the Dokku installation, one of the first prompts you will encounter asks whether to enable the Nginx vhosts plugin. This plugin manages virtual hosts within the Nginx web server, a feature crucial for running multiple applications or services on a single server. Enabling it allows each deployed application to exist on its subdomain.
Setting the IP Address or Hostname with Dokku on Ubuntu
The following prompt requests the IP address or hostname for your Dokku instance. This is where your deployed applications will be accessible. Depending on your setup, you could use a public IP address, a domain, or a subdomain.
Choosing Vhost-Based Deployments with Dokku on Ubuntu
Another crucial decision involves vhost-based deployments. Enabling this feature allows each application you deploy with Dokku to occupy a subdomain of the specified Dokku domain. This functionality is particularly beneficial for hosting multiple applications requiring its namespace.
Specifying the Initial User Keyfile Location with Dokku on Ubuntu
Finally, Dokku installation will ask you to provide a location to store the initial user keyfile. This keyfile is essentially a private key that the system will use to authenticate users during secure transactions, much like an SSH key. You must keep this file safe and secure.
Once you successfully navigate these prompts, you complete your Dokku installation. Consequently, your server now has a powerful PaaS to streamline application deployment processes.
To confirm the successful installation of Dokku, you can execute the following command:
This command displays the installed Dokku version on your server, confirming Dokku’s readiness for use.
Configure Dokku on Ubuntu 22.04 or 20.04
After successfully installing Dokku on your Ubuntu Linux system, the next critical phase is configuration. Configuring Dokku properly ensures the platform will function optimally according to your needs. The following sections will guide you in performing the necessary configuration steps.
Step 1: Initial Dokku Configuration on Ubuntu
Upon first installation, Dokku necessitates initial configuration, typically completed through its web-based setup utility. However, establish your server’s domain name or IP address before accessing this utility. If using a public server with a known domain name or public IP address, initiate the Dokku setup with the following command:
sudo dokku domains:set-global your-domain-name.com
your-domain-name.com with your actual domain name or IP address. This command sets the domain name globally for all apps you’ll deploy using Dokku.
Step 2: Accessing the Dokku Web-Based Setup Utility on Ubuntu
After initial configuration, access the Dokku setup utility by visiting http://your-domain-name.com and replacing your-domain-name.com with the actual domain name or IP address from the previous step.
The setup utility will prompt you for a public SSH key for the dokku user, under which the Dokku daemon operates. Generate a new SSH key pair on your local machine with the ssh-keygen command and paste the public key into the setup utility.
Configuring Environment Variables for Dokku on Ubuntu
Dokku uses environment variables for app configuration. To illustrate, let’s say you’re deploying a Node.js app that requires a specific environment variable. You can set this variable using the following command:
dokku config:set your-app-name NODE_ENV=production
your-app-name with the name of your Dokku app and
NODE_ENV=production with your actual key-value pair.
Configuring Dokku Plugins on Ubuntu
Dokku comes with several plugins that extend its functionality. For example, you can use the plugin to add a MySQL database to your app. First, you need to install the plugin:
sudo dokku plugin:install https://github.com/dokku/dokku-mysql.git mysql
After installing the plugin, you can create a new MySQL database and link it to your app:
sudo dokku mysql:create your-database-name
sudo dokku mysql:link your-database-name your-app-name
your-database-name with the name of your new MySQL database and
your-app-name with the name of your Dokku app.
Install Dokku Plugins on Ubuntu 22.04 or 20.04
Dokku offers a plethora of plugins that you can utilize to extend the functionality of your Dokku installation. These plugins cover many functionalities, such as database support, logging, monitoring, and more. The following sections guide you through the process of installing Dokku plugins.
Understanding Dokku Plugins on Ubuntu
Dokku plugins, repositories that adhere to specific conventions, extend or modify Dokku’s core behavior. Though you can write plugins in any programming language, most developers use shell or Python for simplicity. These plugins offer modular components for commonly used services and tools essential for application deployment and management.
How to Install Dokku Plugins on Ubuntu 22.04 or 20.04
To install a Dokku plugin, you use the
dokku plugin:install command followed by the URL of the plugin’s Git repository. You may also optionally specify a name for the plugin. Here is the general format of the command:
sudo dokku plugin:install <url-of-plugin-repository> <plugin-name>
<url-of-plugin-repository> with the URL of the plugin’s Git repository and
<plugin-name> (optional) with a name for the plugin.
For instance, if you want to install the MySQL plugin for Dokku, you would use the following command:
sudo dokku plugin:install https://github.com/dokku/dokku-mysql.git mysql
In this case,
https://github.com/dokku/dokku-mysql.git is the URL of the Git repository for the MySQL plugin, and
mysql is the name we’ve chosen to give this plugin.
Verifying Dokku Plugin Installation on Ubuntu
After installing a plugin, confirming the installation is a good practice. You can list all the installed plugins using the
dokku plugin command:
sudo dokku plugin
This command will display a list of all installed plugins. If your newly installed plugin is listed, you can conclude that the plugin was installed successfully.
Update Dokku Plugins on Ubuntu 22.04 or 20.04
Updating your Dokku plugins ensures you benefit from the latest features and security fixes. To update all installed plugins, you can use the
dokku plugin:update --all command:
sudo dokku plugin:update --all
Alternatively, if you want to update a specific plugin, you can use the
dokku plugin:update command followed by the name of the plugin:
sudo dokku plugin:update <plugin-name>
<plugin-name> with the name of the plugin you want to update.
Managing Dokku on Ubuntu 22.04 or 20.04
Update Dokku on Ubuntu 22.04 or 20.04
Staying updated with the latest version of Dokku is vital. Doing so ensures you benefit from the latest features, improvements, and security patches, enhancing your deployments’ reliability and robustness. This section outlines the procedure for upgrading your Dokku installation.
Checking Your Current Dokku Version on Ubuntu
Before initiating the upgrade, checking the current Dokku version installed on your system is helpful. This can be done using the following command:
This command will output the current Dokku version, which will be helpful to compare after the upgrade process.
Updating the Package List
The first step in upgrading Dokku is to update your package list. This ensures that your system knows about the latest versions of all packages, including Dokku. Use the following command to update the package list:
sudo apt update
Upgrade Dokku on Ubuntu 22.04 or 20.04
With your package list updated, you can now proceed to upgrade Dokku. The command is as follows:
sudo apt upgrade dokku
This command tells the APT package manager to upgrade the Dokku package specifically. If a newer version of Dokku is available, the package manager will download and install it.
Verifying the Upgrade of Dokku on Ubuntu
After upgrading Dokku, verifying that the upgrade process was successful is recommended. You can check the currently installed Dokku version again using the
dokku version command:
If the version number is higher than before, you have successfully upgraded Dokku.
Considerations After Upgrading Dokku on Ubuntu
Following an upgrade, it’s also a good practice to update your plugins using the command:
sudo dokku plugin:update --all
This ensures compatibility with the latest version of Dokku.
Moreover, always check the release notes or changelog for the new Dokku version. This will inform you of new features, improvements, or breaking changes that could impact your existing applications.
Lastly, test your applications after the upgrade to ensure they work as expected.
Remove Dokku from Ubuntu 22.04 or 20.04
There might be scenarios where you no longer require the Dokku platform and must remove it from your system. The following sections will guide you on completely removing Dokku from your Ubuntu Linux system.
Remove Dokku from Ubuntu
The first step in removing Dokku is to uninstall the software package. To uninstall Dokku, you use the
apt package manager with the
remove command. Here is the command:
sudo apt remove dokku
This command instructs
apt to remove the
dokku package. It will ask for confirmation before proceeding with the uninstallation.
Removing Dokku Dependencies from Ubuntu
After removing the Dokku package, you might want to clean up and remove the dependencies installed with Dokku but no longer needed. Ubuntu’s package manager has a handy command for this:
sudo apt autoremove
This command removes automatically installed packages to satisfy other packages’ dependencies and is no longer needed.
Deleting Dokku Directories from Ubuntu
Some residual data and configuration files might be related to Dokku on your system even after uninstalling the software package and its dependencies. Specifically, Dokku creates directories at
You can remove these directories using the
sudo rm -rf /home/dokku
sudo rm -rf /var/lib/dokku
Be very careful when using the
rm -rf command, as it will permanently delete the specified directory and its contents. Ensure you have no critical data stored in these directories before running these commands.
As we conclude our exploration of Dokku on the Ubuntu Linux distribution, we recognize the remarkable power of this PaaS solution. With Dokku, we’ve navigated through installing, configuring, managing plugins, upgrading, and removing the platform. Its ability to streamline complex deployment tasks and a robust plugin ecosystem make it a reliable and versatile tool for developers and administrators. Through this journey, you’ve gained valuable insights and skills, enabling you to manage Dokku with confidence and precision.