Build your own mini Heroku powered by Docker in 3 simple steps

30 June 2016 by Raza Sayed No comments
Heroku, as you are most probably aware of, is a popular PaaS (Platform as a Service) that allows developers to easily deploy their applications developed using different languages or frameworks to the cloud using a simple ‘git push’. This saves you from having to provision a server yourself for deploying your app which involves installing all the required dependencies on the server, checking config files etc. There are tools to automate server provisioning and deployment for example Vagrant, Chef, Puppet, Ansible, F*cking Shell Script etc, but they have their own learning curve. A PaaS like Heroku takes care of all the deployment for you, literally taking care of the ops in devops so that you can focus on developing great apps rather than on also building the required plumbing. However, this power comes at a cost. They do have cheaper plans for hobbyists but deploying any serious application using Heroku today costs a minimum of $50.


However, if you don’t need all the extras that Heroku offers and just need the simple git push based deployment and Buildpack support then there is an open source alternative called Dokku that anyone can run on their own Linux server running the 64 bit version of Ubuntu 14.04, and have their own PaaS up and running in minutes. For example, if you are using DigitalOcean, you can have your own PaaS up and running in minutes for as low as $5 a month. For the curious, Buildpacks are what Heroku uses to support the automatic deployment of applications developed using different languages or frameworks like Rails, Node.js, Java, PHP etc and there is a separate build pack for each platform. Since all the official build packs have been open sourced by Heroku, Dokku is able to use all of them and you can view the list of those here.


Dokku describes itself as ‘Docker powered mini-Heroku’ and is written in around 200 lines of bash script !. It uses docker to emulate the Heroku-like experience. And though you don’t really need to know a lot about docker and containers to get started with Dokku, however being familiar with them will help you understand how Dokku works and more effectively use it for your own purposes. So before I demonstrate Dokku I will provide a brief introduction.


Docker is the software that allows you to create and manage containers. Containers are analogous to virtual machines in the sense that they allow you to isolate multiple processes or applications. But unlike virtual machines which each have their own copy of the entire operating system, containers share the operating system kernel of the host they are running on, which allows multiple containers to run at the same time on the host operating system which makes them extremely fast and resource efficient as compared to virtual machines.This is made possible by Linux kernel features like LXC and layered file systems like AuFS.  Also since each application is packaged with the entire runtime and dependencies it needs to run, in a container, it can be deployed as is on any system with Docker installed so it doesn’t matter which system you used to develop your app and which one you are deploying it on making your apps truly portable as in ‘write once run anywhere !’ .


Now container based virtualization support has been available in Linux kernel since long but it was not simple to use.Docker has made containers easily accessible to everyone.However, Docker alone does not allow for the easy Heroku-like deployment. And this where platforms like Dokku come in which stand on the shoulders of giants and use Docker under the hood and also various other open source projects like gitreceive, build step and Nginx to provide the PaaS experience.


To demonstrate Dokku I will deploy a simple Node.js application to a Linux VPS running Ubuntu 14.04 x64 in 3 steps.


Step 1. On your local machine run the following command to fetch the sample node.js app.
Step 2.  (One time step) On your server install dokku using the following two commands as a user with Sudo access. If you are using Digital Ocean then you can entirely skip these two commands and use their one-click install to create a server with Dokku pre-installed.
Then just navigate to your server ip and add your domain (if you have one) and add your public ssh key to finish the configuration.


Step 3. And finally, the below 2 commands in your application directory to deploy the app !.You can change my-node-app to whatever another name you want.


And voila, within a few minutes your app would be up and running at ‘http://your-domain-or-server-ip-here’. It’s really that simple!.


To get a peek behind the scenes and confirm that the application is really being run inside a container, run the command ‘docker ps‘ on the server and see the container running the nodejs application.


For more information on dokku checkout Also, there is another project called dokku-alt, stands for dokku-alternative, which is a fork of dokku and comes with a lot of commonly used plugins like data stores etc preinstalled. Hope this post has whetted your appetite for Dooku in particular and also docker and container technology in general and you would explore it in more detail. If you need further help or clarification on anything above then you can reach out to me at Happy Hacking !.

Raza Sayed

Follow me on Twitter

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe To Our Blog

Get access to proven marketing ideas, latest trends and best practices.

Next up home


Lets build cool stuff

Share your contact information & we will get in touch!

I want (Tell us more about your dream project)