Installing dokku on an Amazon EC2 instance running 64-bit Ubuntu 12.04 LTS.

Most of my self-learning Django/python projects are deployed on Heroku. The free instances that Heroku provides provide a great way for newbie developers like me to set up prototypes of ideas without worrying about having to spend a bomb. Therefore, when dokku, a privately deployable heroku-like PaaS, began making waves in the dev community my curiosity was obviously stoked.

The documentation for dokku is fairly straightforward. The only hitch I could find was that I was running a 64-bit Ubuntu 12.04 LTS on my EC2 and dokku recommended a 64-bit Ubuntu 13.04. I checked the screencast and it seemed to mention that dokku might still work on 12.04, so I wondered if I should try my hand at installing it anyway. Turns out, it took me the better part of the day to get dokku to install on Ubuntu 12.04 but I managed to get it installed, finally.

Note the choice of words – installed, not working. There’s a reason for that, I’ll come to that later.

I followed the excellent tutorial/post titled “Deploying a Django App on Dokku” by Michael Herman on for the most part, although, following the README on dokku’s github page would also be equally beneficial, I guess.

As expected, the make command failed with the following error:

...blah blah blah...

Selecting previously unselected package lxc-docker-0.6.1.
(Reading database ... 58155 files and directories currently installed.)
Unpacking lxc-docker-0.6.1 (from .../lxc-docker-0.6.1_0.6.1_amd64.deb) ...
Replacing files in old package lxc-docker ...
Preparing to replace lxc-docker 0.5.3-1 (using .../lxc-docker_0.6.1_amd64.deb) ...
docker stop/waiting
Unpacking replacement lxc-docker ...
Processing triggers for ureadahead ...
Setting up lxc-docker-0.6.1 (0.6.1) ...
stop: Unknown instance: 
docker start/running, process 1805
Setting up lxc-docker (0.6.1) ...
sleep 2 # give docker a moment i guess
runtime: panic before malloc heap initialized
fatal error: runtime: cannot allocate heap metadata
runtime: panic before malloc heap initialized
fatal error: runtime: cannot allocate heap metadata
make: *** [stack] Error 2

Trawling the Github issues page for dokku led me to Issue 51 that claimed that this was being caused because the micro EC2 instance doesn’t have enough memory to let docker run. The solution was to create a swapfile and the instructions were, quite helpfully, given in the issue discussion itself.

# dd if=/dev/zero of=/swapfile bs=1024 count=1024000
# mkswap /swapfile
# swapon /swapfile 

(A slightly more detailed version is also available here.)

Great. Swapfile created, switched on and added to /etc/fstab as well. Let’s try rebooting and installing dokku again. Another error:

... blah blah blah...

apt-get install -y lxc-docker 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
lxc-docker is already the newest version.
The following packages were automatically installed and are no longer required:
  bsdtar libnettle4 libarchive12
Use 'apt-get autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
sleep 2 # give docker a moment i guess
2013/09/17 08:50:49 Can't connect to docker daemon. Is 'docker -d' running on this host?
2013/09/17 08:50:49 dial unix /var/run/docker.sock: connection refused
make: *** [stack] Error 1

Hmm, so docker couldn’t run as a daemon for some reason? Alright, hunt some more. click What is this? LTS Ubuntu with Docker on Digital Ocean Seems promising. Okay, Ken Conchrane says here that docker doesn’t play nice with kernel version < 3.8. Alright, let’s see if we can update the kernel.

$ sudo apt-get dist-upgrade

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following NEW packages will be installed:
  linux-headers-3.2.0-53 linux-headers-3.2.0-53-virtual linux-image-3.2.0-53-virtual
The following packages will be upgraded:
  linux-headers-virtual linux-image-virtual linux-virtual
3 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 25.6 MB of archives.
After this operation, 104 MB of additional disk space will be used.
Do you want to continue [Y/n]?

Drat. I was kinda hoping it would pick up the 3.8 kernel or better. Turns out it only picks up the minor version updates. Well, let’s upgrade it anyway and then think of ways to get the 3.8 kernel onto an existing EC2 instance. The next few hours were spent as follows:

  • Browse the AWS fora, IRC channels, etc trying to see if you can upgrade the kernel for an existing EC2 instance. Get various answers, none of which seem promising.
  • Wondering if I should email AWS and ask if they can help.

I finally decided to re-read the issue page to see if someone had another solution. It was then that I spotted @5HT saying, ‘Short: we just need linux-image-extra-* compatible with kernel.’ towards the end of the conversation.

Could it really be that simple?

Run dpkg --list | grep linux-image. Hmmm, The kernel is but the extra package for it doesn’t seem to be installed. Okay, run sudo apt-get install linux-image-extra- Reboot the machine. Wait a few seconds, ssh back into it. cd into your dokku folder and re-run the installation.


I followed the rest of the tutorial and everything went fairly as expected. Just a note: if the gitreceive upload-key command causes problems, try running it with a sudo, i.e.:

$ cat ~/.ssh/ | ssh [USER]@[MACHINEADDRESS] "sudo gitreceive upload-key [REPO_PUSH_NAME]   

For instance, I switched [REPO_PUSH_NAME] with dokku by running:

$ cat ~/.ssh/ | ssh [USER]@[MACHINEADDRESS] "sudo gitreceive upload-key dokku

I was able to git push my existing update-me local git repo without a hitch. However, since I had forgotten to set up my VHOST file (as required and mentioned in the dokku GitHub README at the very beginning) the deploy didn’t work properly – as in, nothing appeared when I opened the page in the browser. Also, I hadn’t set up my databases, so there’s that.

I’ll post an update here when I get that working. Cheers!