This tutorial will enable you to install Zoneminder 35.16 on Ubuntu 20.04 using a Docker container. Docker, in my opinion, represents a further abstraction of the software architecture and thus makes a simple operation more complex. But while it is tricky to initially set up, once you do it, it works well. Anecdotally, I have noticed on two BHYVE virtual servers I have built this project on, I find the Docker version runs much more efficiently that a traditional install and that the server load is less than half when run inside the Docker container.
Firstly, I created this version on TrueNAS v. 12 using a virtual BHYVE instance which, having worked with KVM vm’s previously, I find the FreeNAS/TrueNAS virtual servers MUCH easier to use, snapshot and work with. Though if you are using other platforms, this tutorial should work for you as well. This tutorial assumes you have created an instance with one cpu and eight GB of ram and a 100gb virtual disk for the OS and a 500 GB or greater volume for camera storage (use ‘virtio’ if you’re using BHYVE). This how-to works with Ubuntu 20.04, though it should work on other distros/UB versions, ymmv. It assumes that you have Docker installed and properly tested. If you are new to Docker, click on this link for a quick tutorial to get you up and running. So let’s get started:
Here are the steps I followed to get Zoneminder 35.16 on Ubuntu 20.04:
1 – Pull docker image:
2 – Open a ssh command prompt and run the command below to create the Zoneminder container. For more information on the different options set below click here. Copy the command below as one block of text and paste it into the command window (change the timezone option and the /mnt/ option to suit your environment (**see step 6 below for more info about mounting external drives before you press enter):
3 – After the Zoneminder container is installed we need to fix the MariaDB instance, which on my installation at least, didn’t run and generated an error, resulting in Zoneminder not starting. So enter bash shell on your docker instance:
Remove the zm database:
4 – Now create new zm db (root password is empty, but you can change it if you wish) and start mysql and Zoneminder
5 – Now we need to adjust the NO_START_ZM=”1″ environment variable so Zoneminder will start automagically when the container in started. I know you can spawn a new container with the modified variable and delete the old one AND rename the modified one, etc. But I prefer to edit the json and just modify the existing container (see my abstraction comment in the preamble). Find your container and edit it as follows to remove: ,”NO_START_ZM=1″ to “NO_START_ZM=0” from the “Env”:[] section and save.
6 – If you adjusted the variables in step 2 above you can skip this step, but I just wanted to provide readers with some context as to why we set these particular settings and what they do. Zoneminder, by its design uses a lot of disk space which is stored by default in the ‘/var/cache/zoneminder/events’ folder. Now it is not a good idea to put this folder on the same drive as your ‘/’ folder due to the fact that if your hard drive fills up completely, your system will die. So I like to mount an additional drive just to store the camera recordings and associated data.
The json syntax is as follows: {“Source”:”[/my_external_drive]”,”Destination”:”/var/cache/zoneminder” *remember, /mnt/zoneminder is mounted internally inside your container by default so you want to change that line to your external drive which you have previously mounted to your vm. Change the line: ,”MountPoints”: and change {“Source”:”/mnt/zoneminder”,”Destination”:”/var/cache/zoneminder” to {“Source”:”/var/cache/zoneminder”,”Destination”:”/var/cache/zoneminder” Also, using this step will allow those of you who need to mount more than one storage volume to your container do so easily by adding more mount points.
7 – Now we have Zoneminder up and running we need to make it reachable from the outside world. To do this we are going to set up apache2 outside the container, configure a Let’s Encrypt certificate for it and establish a proxy connection to our webserver inside the Docker container which we have set up to listen on ports 8080 and 8443.
8 – Create a Let’s Encrypt Certificate.
9 – Set up the zm.example.com.conf file. Paste the following below into zm.example.com.conf replacing existing text. Adjust servername and your local host’s IP (don’t use ‘localhost’)
10 – Enable ssmtp for sending mail from Zoneminder
Add the following below to your revaliases file (change your settings to suit)
Now edit your ssmtp file.
Test your mail.
Still not working as you expect? Check out the log files by running #docker logs -f Zoneminder before you post a comment. Still not working? Just telling me, ‘it’s not working’, does not provide enough information to troubleshoot your problem. You wouldn’t take your car into the garage and say, “my car doesn’t work!” – you need to give me some clues to help you fix your problem. Check your steps carefully, every command has to be issued as it is shown in the how to. If you find any mistakes please let me know and I will fix them right away.
Thanks for the guide!