When I retired my 2008 macbook a couple of years ago I put it in a corner to use as a server. I started running Airvision 2 to host my Aircam security camera. I ran the software on an Ubuntu guest in a Parallels VM. Version 3 of airvision (since renamed Unifi Video ) has been out for quite some time and I decided to try to upgrade for several reasons. I discovered a docker container for unifi-video and since I’ve been hearing about docker for quite a while, and thinking docker would probably be less resource intensive than parallels, I decided to try to install it. It took more research than I expected but the results are satisfying. Here’s how to do it.
Installing Docker
Windows/ Mac: Codec for Media Player: Codec for Windows Media Player: Platinum Series: Download: Web Component for IP Camera (Mac) Web component for Safari (up to version 11) IPCMacV11: Platinum Series: Download: Web Component for DVR/NVR (Mac) Web component for Safari (up to version 11) NVR&DVRMacV11: Platinum Series: Download: Sapphire. Jun 23, 2020 The UniFi NVR (network video recorder) is the central hub of the UniFi Video system, and it comes pre-installed with UniFi’s video software to deploy and manage your cameras. Additionally, the UniFi NVR has a 2 TB hard drive that can store up to 700 hours of.
Unifi Video Software
It’s quite easy with Docker Toolbox. The DMG package includes VirtualBox and a VM management tool called
docker machine
as well as, of course, docker
and a few other goodies. Follow the instructions to run the quick-start terminal at the end of the installation and you’ll have a VM called default
ready and running. It’s a good idea to run through the Docker User Guide at this point and run a couple of example containers.Unifi Nvr Firmware
Installing the Unifi video container
Look at the README at Rednut’s github site and follow the instructions to clone the repository. (The instructions suggest you could alternatively use
docker pull
but that didn’t work for me and anyway we need to alter the Dockerfile
slightly before building.)Data Shares
This is where the first complication pops up. The
docker run
command Rednut includes in his README has options of the form -v HOSTDIR:/usr/lib/unifi-video
. This maps a directory in the container to a shared directory in the host. This is a very useful feature. It allows us to access the important state of the app — the data and logs — without mucking around in the container’s filesystem, and allows us to conveniently back up that state with Time Machine or whatever, without the need to back up the VM or container at all (it can easily be reinstalled if necessary.) However this feature does not work so well on the mac — we’ll need to do a hack.But for now, let’s just run the thing and see if we can get something working. Go ahead and run
docker build -t=rednut/unifi-video .
(this will take some time) and then the docker run
command without the two -v
options. This should fire up a working unifi-video controller that you can access in your browser using the IP returned by docker-machine ip default
as https://default-ip:7443
. But don’t get excited and start setting it up yet. We’ve got a long way to go.The shared directory thing doesn’t work on the mac because of the way the intermediate virtualbox VM implements sharing. Yes, by default, /Users is shared, but it can only be written by a process in the container running as
root
or docker
. So we have to make the unifi-video user masquerade as the docker user. Add the following lines to Dockerfile near the end just before the WORKDIR
and CMD
commands:Now run
docker build -t=rednut/unifi-video .
again. (This time it will build very fast because previous layers have been cached.) And then decide where you want to keep your data and logs. I put them in a docker directory in my home directory. Now start up the container like this. (Oh, yes. First, please stop and remove the previous invocation with docker rm -v unifi-video
.)Now you should see a bunch of logs in
~/docker/unifi-video/logs
. In particular you’ll notice that error.log
and mongod.log
indicate there’s a serious problem. mongo won’t start because it runs as its own user and can’t write to the shared data directory. Oh, dear. We can’t use the usermod hack to map two different users to the same user. And just changing the mongod user to be in group staff doesn’t help either.One promising approach I tried that didn’t work was to tell VirtualBox to mount the shared directory using NFS. It is detailed in boot2docker issue 160.
This works well enough to allow all users to write through, but the problem is, mongo doesn’t work with NFS!
This works well enough to allow all users to write through, but the problem is, mongo doesn’t work with NFS!
So what we’ll have to do is run mongo natively on the Mac and let unifi-video container connect to it with a socket.
Installing mongodb
It’s pretty easy to get mongo going with homebrew. Detailed steps are here. But before starting the mongo daemon we need to make a couple of changes to the configuration file at
/usr/local/etc/mongod.conf
. First of all, delete the following lines:This will allow mongo to listen to all network interfaces on the mac, especially the interface with the VirtualBox VM. (Or you can specify this interface explicitly if you want to be more rigorous.)
Then, if you’d like mongo to store its files in the same area as the unifi-video files, change the log and storage options:
Start mongo with
launchctl load
.Unifi Video Software For Mac
Now stop the unifi-video container again. Connect to mongodb by editing the file
/Users/me/docker/unifi-video/data/system.properties
so it looks like this:Now run
The log files should indicate a connection with mongo and you should be able to see the app in your browser again. But we’ve still got a few more details to address.
docker restart unifi-video
.The log files should indicate a connection with mongo and you should be able to see the app in your browser again. But we’ve still got a few more details to address.
Accessing the app from other hosts
Right now you can access the app at
https://docker-default-ip:7443
. But you need to be able to see it from other hosts on the LAN and, by port forwarding from the LAN router, the outside internet. You can see some of my struggles in getting this going by reading my StackOverflow question. But you don’t need to. The answer is quite simple, and here it is.Use NAT port forwarding on the VM. You can either use the VirtualBox GUI to set up the ports you’re forwarding in the NAT network adaptor (Adaptor 1), or use the following commands:
Now stop and remove your unifi-video container and run it again without the
-p
options but with the —net=host
option like this:Now you should be able to see the app at
localhost:7443
on your mac and at YOUR_MAC_IP:7443 from other machines on the LAN. Yea!I guess you could go ahead now and create an admin account and login and start playing with your video controller. But there’s still a couple of more details to consider.
Make sure everything runs automatically at reboot.
This page has pretty straightforward instructions on how to set up launchd to run the VM at login (you either need to have your mac set up to automatically log you in at reboot or install it as a system launchagent). Stop and remove the unifi-video container again and execute the
docker run
command again adding the option --restart=always
.And if you haven’t done so already, follow the instructions on the mongo installation page to set up launchd. Almost done.
Time machine
Still working on this one. I think all you have to do is find the the virtual box VM file and exclude it in Time Machine options.
Setting up Unifi Video
I’ll let you follow the Ubiquiti docs on this. On thing that is missing in Unifi Video compared to my old Airvision 2 setup is push notifications. I had to do a fair amount of hacking to get that one to work. I use the Prowl app on the mac to receive push notifications. You can activate prowl by sending an email to a special address. Before, I could open the notification in prowl and click on the URL and view the recording in Safari. Now that doesn’t seem to work, you have to use the UniFi Video app. Although the app is nice, it doesn’t launch automatically. I don’t know if Ubiquiti is working on a push notification feature for the app, but a drop-dead simple workaround would be if they simply added a
URL Scheme
to the app. Then you could set up Prowl to automatically redirect and open the app when notified.Issues
At the moment I’m having the following issues:
1. NTP — the VirtualBox VM is not keeping time well, as a result the timestamp on the camera image and recordings is off. The time gets set correctly when the VM is restarted but it rapidly gets behind. It’s lost 10 minutes in a few hours.
2. I am getting flooded with emails saying that Aircam has lost connection — one a minute. And it clearly has not lost connection as I’m sitting here watching the live view and getting prowl notifications of motion recordings.
1. NTP — the VirtualBox VM is not keeping time well, as a result the timestamp on the camera image and recordings is off. The time gets set correctly when the VM is restarted but it rapidly gets behind. It’s lost 10 minutes in a few hours.
2. I am getting flooded with emails saying that Aircam has lost connection — one a minute. And it clearly has not lost connection as I’m sitting here watching the live view and getting prowl notifications of motion recordings.
Update.
It is clear that issue #2 is caused by issue #1. The camera has its time syncronized from the NVR. The camera clock runs at normal speed, but every minute or two it gets a message from the NVR telling it to set its clock back by 10 or 20 seconds or more. The camera gets confused and drops off line for a few seconds.
I have worked around this by downgrading Virtualbox from 5.0.4 to 4.3.30. See the discussion on Docker Toolbox Issue 193. Everything is working great now.
SecuritySpy is NVR (Network Video Recording) software that will enable you to quickly set up an effective video surveillance system of any size, from home or office installations to large-scale professional systems with hundreds of cameras.
Flexible recording features provide high-quality continuous or motion-triggered recording, while emails, notifications and alarms can also be triggered by motion detection. Remote monitoring features allow you to view and manage your system from anywhere in the world.
SecuritySpy features smart motion detection powered by AI. Deep neural networks intelligently analyse video footage to decide when to trigger recording and notifications. This provides a high degree of accuracy, and can eliminate false-positive detections.
SecuritySpy's user interface is meticulously designed and easy to use:
With hardware-accelerated video processing, multi-threading and other optimisations, SecuritySpy can take full advantage of the power of your Mac, providing high performance with large numbers of cameras.
SecuritySpy integrates with virtually all IP cameras on the market, including devices from these brands: