Common Dokku Pitfalls
Sunday, 7 December 2014Dokku is a Docker powered Heroku clone which you can install on your own hardware. I’ve been using it for over a year now and have recently moved all of my sites over to run on it. It doesn’t come without its quirks, see below for more.
1. Insufficient physical memory
runtime: panic before malloc heap initialized
fatal error: runtime: cannot allocate heap metadata
Solution: Configure virtual memory (swap file).
dd if=/dev/zero of=/swapfile bs=1M count=512
mkswap /swapfile
chmod 600 /swapfile
Then add the following to /etc/fstab
:
/swapfile none swap sw 0 0
Then run the following to persist it.
swapon -a
2. Python/Ruby app incorrectly detected as Node app
This is down to the presence of a package.json
file in your app root.
-----> Building node-js-app ...
Node.js app detected
Solution 1: Set your build pack explicitly to Python (see below). Then install Node.js via dokku-nodejs.
Solution 2: Use heroku-buildpack-multi to set both buildpacks (I haven’t tested this solution).
This way your app will be correctly built as well as your package.json
dependencies installed.
3. TLS/SSL config + custom domain plugin incompatibilities
Using plugins such as dokku-domains-plugin or dokku-custom-domains, in combination with Dokku’s TLS support can result in unexpected TLS behaviour (i.e. Some certificates not being applied).
Solution: Use the dokku-nginx-hostname plugin which is compatible with Dokku’s TLS/SSL.
4. BUILDPACK_URL
env var not recognised by build
Solution: Create file .env
in the root of your app.
Add your build pack to it:
echo "export BUILDPACK_URL=https://github.com/heroku/heroku-buildpack-python" > .env
NOTE: This has been fixed in Dokku >=0.3.9.
5. Cannot deploy static app
buildpack-nginx doesn’t support Dokku >0.3 (Ubuntu 14.04).
Err http://archive.ubuntu.com quantal/main amd64 Packages
404 Not Found [IP: 91.189.91.15 80]
Err http://archive.ubuntu.com quantal/restricted amd64 Packages
404 Not Found [IP: 91.189.91.15 80]
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/quantal-security/main/binary-amd64/Packages 404 Not Found [IP: 91.189.91.15 80]
Solution: Use the following build pack https://github.com/ademuk/buildpack-nginx
See above on how to apply it.