UPDATE: Some recent changes to ohardy/dokku-mariadb have resolved the problems with losing DB links on reboot.
I decided to jump in and set up my own mini-Heroku with Docker and Dokku as seems to be the fashion at the moment. Here are my thoughts and a few of the issues I hit along the way. Using Dokku v0.2.3.
Dokku allows applications to be configured using enviornment variables as described in the twelve-factor app:
That won’t work though, because Dokku’s command line app doesn’t support spaces in config variables. You can get around this by setting the configuration directly in
They won’t be correctly reported by
dokku config acme, but they’ll work.
You can backup Dokku’s configuration (including application configuration) with:
This will place the backup in
Multiple Domains and Basic Auth
I installed a couple of plugins which worked well out of the box:
Secures an individual app with HTTP Basic authentication. Dead simple to use and useful when deploying apps for testing or private use only.
Configure additional custom domains for your dokku app.
Dokku has plenty of plugins for different data stores. I decided to work with ohardy/dokku-mariadb since on a VPS with farily limited memory, I preferred to only run one container and a single instance of MariaDB.
The main problem I faced here was keeping database connections working after a reboot. On reboot, docker containers are restarted and will receive a new private IP. This means that the
DATABASE_URL used by the apps, e.g.
mysql://[PRIVATE_IP]:3306/[database] will change and break database connections. Despite some discussion and attempted fixes, the multiple container dokku MariaDB plugin (kloadut/dokku-md-plugin) uses a dynamic port for each container, which also changes on reboot, so suffers from the same problem.
I fixed this issue in watsonbox/dokku-mariadb:reboot-persist-connections by patching ohardy/dokku-mariadb to use a fixed IP address. It also uses a fixed port (3306), since only one container/instance is created.
Worth noting that ohardy/dokku-mariadb stores persistent DB data on the host in
/home/dokku/.o_mariadb (kloadut/dokku-md-plugin in