UniFi controller in Docker

I recently ordered a 3-pack of the Ubiquity UniFI-APs. While I am waiting for them to arrive, I thought I would set up my controller software to run locally on my network. In Ubuntu, to do this, you can simply install the DEB package, or setup the apt source list and install the package and start the service. Although, I decided I would like to run everything in docker containers, as one does. So far, I have created a Dockerfile that I can use by doing the following:

FROM ubuntu:14.04
MAINTAINER BK Box “bk@theboxes.org
RUN sudo apt-key adv — keyserver keyserver.ubuntu.com — recv C0A52C50; \ echo “deb http://www.ubnt.com/downloads/unifi/debian stable ubiquiti” | sudo tee -a /etc/apt/sources.list; \ apt-get -y update; \ apt-get -y upgrade; \ apt-get -y install unifi
RUN apt-get clean
RUN rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
VOLUME [“/var/lib/unifi”]
WORKDIR /usr/lib/unifi
ENTRYPOINT java -jar lib/ace.jar start

The only problem with this is that I have yet to find a way to tell the UniFi package to start and connect to a remote MongoDB instance. UniFi will, by default, start it’s own MongoDB instance running locally. After digging around on the forums, it appears that UniFi simply wants to run this locally no matter what, and will even initiate a shutdown when connecting to the port if a previous instance is already running. There is mention of someone who created a proxy to listen on that port and ignore that shutdown while allowing all other traffic to route to another instance, but I have not found this proxy anywhere yet.

For now, I will just roll with this and see how well it works out when I get the APs in and setup. This solution does not give me a host volume for persistent data and backups, but that will be next.

Yes, there is plenty of room for improvement. For example, I am considering building from Alpine Linux instead of Ubuntu since this will cut down on the container size significantly.

You can find my changes on github or pull images from docker hub or quay.io.

Continue to Part 2