{"id":462,"date":"2024-11-07T22:42:37","date_gmt":"2024-11-07T22:42:37","guid":{"rendered":"https:\/\/blog.hostinger.io\/support\/2024\/11\/07\/10100263-how-to-use-the-dokku-vps-template\/"},"modified":"2024-11-07T22:42:37","modified_gmt":"2024-11-07T22:42:37","slug":"10100263-how-to-use-the-dokku-vps-template","status":"publish","type":"post","link":"https:\/\/www.hostinger.com\/support\/10100263-how-to-use-the-dokku-vps-template\/","title":{"rendered":"How to use the Dokku VPS template"},"content":{"rendered":"<p class=\"no-margin\">Dokku is an open-source Platform as a Service (PaaS) that simplifies application deployment using Docker containers. Installing the Dokku template on your VPS allows you to easily manage and deploy applications. <\/p><p class=\"no-margin\">\n<\/p><div class=\"intercom-interblocks-callout\" style=\"background-color: #e8e8e880;border-color: #73737633\">\n<p class=\"no-margin\">If you don&rsquo;t have a VPS yet, check the available options here: <a href=\"https:\/\/www.hostinger.com\/vps\/dokku-hosting\" target=\"_blank\" class=\"intercom-content-link\">Dokku VPS hosting<\/a> <b>&#128640;<\/b><\/p>\n<\/div><p class=\"no-margin\">\n<\/p><p class=\"no-margin\">Here&rsquo;s a step-by-step guide to get you started, with a sample Getting Started Ruby App:<\/p><p class=\"no-margin\">\n<\/p><h2 id=\"h_b8efe7f063\"><b>Step 1: Connect to Your VPS<\/b><\/h2><p class=\"no-margin\">Use SSH to access your VPS. Open your terminal and run:<\/p><p class=\"no-margin\">\n<\/p><pre><code>ssh root@your_vps_ip<\/code><\/pre><p class=\"no-margin\">Replace <code>your_vps_ip<\/code> with your <a href=\"\/support\/5139756-how-to-find-your-vps-ip-address\" target=\"_blank\" class=\"intercom-content-link\">VPS&rsquo;s IP address<\/a>. Enter your VPS password when prompted.<\/p><p class=\"no-margin\">\n<\/p><h2 id=\"h_1fb30d8006\"><b>Step 2: Verify Dokku Installation<\/b><\/h2><p class=\"no-margin\">After logging in, ensure Dokku is installed by checking its version:<br>&#8203;<\/p><pre><code>dokku version<\/code><\/pre><p class=\"no-margin\">If Dokku is installed correctly, this command will display the installed version.<\/p><p class=\"no-margin\">\n<\/p><h2 id=\"h_880b3cfaed\"><b>Step 3: Finish configuring Dokku for VPS<\/b><\/h2><p class=\"no-margin\">you can use any domain you already have access to, this domain should have an A record or CNAME <a href=\"\/support\/1583227-how-to-point-a-domain-to-your-vps\" target=\"_blank\" class=\"intercom-content-link\">pointing at your server&rsquo;s IP<\/a>:<\/p><p class=\"no-margin\">\n<\/p><pre><code>dokku domains:set-global example.vps<\/code><\/pre><p class=\"no-margin\">or you can also use the IP of your server:<\/p><p class=\"no-margin\">\n<\/p><pre><code>dokku domains:set-global 222.222.22.22<\/code><\/pre><p class=\"no-margin\">On your <b>local machine<\/b> (not VPS) run:<\/p><p class=\"no-margin\">\n<\/p><pre><code>cat ~\/.ssh\/your_key.pub | ssh root@your_vps_ip dokku ssh-keys:add name<\/code><\/pre><p class=\"no-margin\">replace <code>your_key.pub<\/code> with your local SSH public key, <code>your_vps_ip<\/code> with your VPS IP and <code>name<\/code> with a preferred name. Enter your VPS password when prompted.<\/p><p class=\"no-margin\">\n<\/p><h2 id=\"h_9154540e44\"><b>Step 4: Create a Dokku Application<\/b><\/h2><p class=\"no-margin\">Download Ruby Getting Started application on your <b>local machine<\/b>:<\/p><p class=\"no-margin\">\n<\/p><pre><code>git clone https:\/\/github.com\/heroku\/ruby-getting-started<\/code><\/pre><p class=\"no-margin\">Return to your <b>VPS terminal<\/b> and run this command:<\/p><p class=\"no-margin\">\n<\/p><pre><code>dokku apps:create ruby-getting-started<\/code><\/pre><p class=\"no-margin\">This initializes an app on Dokku with the specified name (replace <code>ruby-getting-started<\/code> with your desired app name)<\/p><div class=\"intercom-interblocks-callout\" style=\"background-color: #e3e7fa80;border-color: #334bfa33\">\n<p class=\"no-margin\">Dokku by default <b>does not<\/b> provide datastores (e.g. MySQL, PostgreSQL) on a newly created app.<\/p>\n<\/div><p class=\"no-margin\">The Getting Started app requires a PostgreSQL service, so install the plugin and create the related service as follows:<\/p><p class=\"no-margin\">\n<\/p><pre><code>sudo dokku plugin:install https:\/\/github.com\/dokku\/dokku-postgres.git<\/code><\/pre><p class=\"no-margin\">After that, run the following:<\/p><p class=\"no-margin\">\n<\/p><pre><code>dokku postgres:create railsdatabase<\/code><\/pre><p class=\"no-margin\">Replace <code>railsdatabase<\/code> with a preferred name.<\/p><p class=\"no-margin\">\n<\/p><p class=\"no-margin\">Then link your app with a database:<\/p><p class=\"no-margin\">\n<\/p><pre><code>dokku postgres:link railsdatabase ruby-getting-started<\/code><\/pre><p class=\"no-margin\">On your <b>local machine<\/b> run:<\/p><p class=\"no-margin\">\n<\/p><pre><code>cd ruby-getting-started<br>git remote add dokku dokku@your_vps_ip:your_application_name<br>git push dokku main<\/code><\/pre><p class=\"no-margin\">Replace <code>your_vps_ip<\/code> with a your VPS IP address and <code>your_application_name<\/code> with your created application name.<\/p><div class=\"intercom-interblocks-callout\" style=\"background-color: #e3e7fa80;border-color: #334bfa33\">\n<p class=\"no-margin\"><b>Note<\/b>: the remote username <b>must<\/b> be dokku or pushes will fail<\/p>\n<\/div><p class=\"no-margin\">After running <code>git push dokku main<\/code>, it should start building the app and give you a domain or IP address to enter your app.<\/p><p class=\"no-margin\">\n<\/p><h2 id=\"h_5936d0e43d\"><b>Step 5: Access Your Application<\/b><\/h2><p class=\"no-margin\">Once Dokku completes the build and deployment, your app should be accessible at:<\/p><ul>\n<li>\n<p class=\"no-margin\"><code>http:\/\/your_server_ip:port<\/code> if you don&rsquo;t have a domain set up.<\/p>\n<\/li>\n<li>\n<p class=\"no-margin\"><code>http:\/\/your_app_name.yourdomain.com<\/code> if you&rsquo;ve configured a domain for Dokku.<\/p>\n<\/li>\n<\/ul><p class=\"no-margin\">You can also check the terminal and search for the Application deployed: <code>http:\/\/your_server_ip:port<\/code><\/p><p class=\"no-margin\">\n<\/p><p class=\"no-margin\">That it! Your Getting Started application is ready to be accessed!<\/p><div class=\"intercom-interblocks-callout\" style=\"background-color: #e3e7fa80;border-color: #334bfa33\">\n<p class=\"no-margin\">For comprehensive documentation and advanced configurations, visit the<a href=\"https:\/\/dokku.com\/docs\/getting-started\/installation\/\" target=\"_blank\" class=\"intercom-content-link\" rel=\"noopener\"> Dokku Documentation<\/a>.<\/p>\n<\/div><p class=\"no-margin\">\n<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to get started with Dokku template on Hostinger VPS<\/p>\n","protected":false},"author":581,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"include_on_kodee":true,"footnotes":""},"categories":[206],"tags":[],"class_list":["post-462","post","type-post","status-publish","format-standard","hentry","category-vps-os-and-templates"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/support\/10100263-how-to-use-the-dokku-vps-template\/","default":1}],"include_on_kodee":true,"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/462","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/users\/581"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/comments?post=462"}],"version-history":[{"count":0,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/posts\/462\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/media?parent=462"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/categories?post=462"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/support\/wp-json\/wp\/v2\/tags?post=462"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}