How to Build a Zoneminder-master Docker-Image with MYSQL 8 & MSMTP

We observed that most of the Linux software have compatibility problems due to dependency issues when operating systems are upgraded.  To overcome dependency issues and to avoid conflicts with the default system structure of the OS , the Docker-images play an important role.

Since the official Zoneminder eoan has Dependency wait on lgw01-amd64-051 , I thought of developing a docker-image  with MYSQL 8 & MSMTP and push to docker hub  .

This docker image is structured based on the basic concepts in my earlier post on How to install Zoneminder , ( v1.33.16.) with Mysql 8 on Ubuntu 19.10

This image is created on ubuntu:eoan  with zoneminder-master/ubuntu disco main

In the Dockerfile , Ubuntu environment used is ubuntu:eoan. deb

For Zoneminder ppa used is http://ppa.launchpad.net/iconnor/zoneminder-master/ubuntu disco main .

Therefore libmysqlclient20 has to be installed to overcome when  zoneminder-eoan is installing on ubuntu:eoan .

When composing the zoneminder docker image , we are placing the Dockerfile, entrypoint.sh and the downloaded libmysqlclient20_5.7.27-0ubuntu0.19.04.1_amd64.deb files in the same folder .  The folder that I have used  is ~/Documents/zm-docker-d2 .  You can select any folder. Please see the Figure below.

Screenshot from 2020-01-15 08-41-44

Figure:- 1 Dockerfile, entrypoint.sh and libmysqlclient20 at the folder ~/Documents/zm-docker-d2

Installation of Docker on Ubuntu 19.10

On the Ubuntu terminal

sudo apt install docker.io

Then open the Ubuntu terminal

Go the folder where the Dockerfile , entrypoint.sh and libmysqlclient20 are placed

( Note:-

The Dockerfile  and  entrypoint.sh can be copied from the following my post at GitHub

https://github.com/bkjaya2020/bkjaya1952-docker-zoneminder-master-mysql8-   )

On the Ubuntu teminal

 

docker build --tag=mysql8zm . # Dockerfile

( The name tag given for the image is mysql8zm. you can give any name)

Screenshot from 2020-01-14 17-49-47

Figure:-2

Screenshot from 2020-01-14 17-50-55.png

Figure:-3

Now you  can see from the above figure ,the docker-image “mysql8zm” , has been created successfully.

sudo docker images

Screenshot from 2020-01-14 17-51-56

Figure:-4  The created docker-zoneminder image  “mysql8zm” after completion of compose

Tagging the image and pushing to the docker hub

first you will have to signup & open  a Docker Hub account at https://hub.docker.com/

Then login to the Docker Hub account

sudo docker login

sudo docker tag mysql8zm bkjaya1952/docker-zoneminder-master-mysql8:1.33.16

sudo docker push bkjaya1952/docker-zoneminder-master-mysql8:1.33.16

 

Screenshot from 2020-01-14 21-00-51

figure:- 5  Tagging  & pushing  the image to the Docker hub

Screenshot from 2020-01-14 23-43-41

Figure:- 6 The pushed bkjaya1952/docker-zoneminder-master-mysql8:1.33.16 Repository at the Docker hub

The installation details of the docker-zoneminder-master-mysql8:1.33.16 can be obtained from the following links.

https://hub.docker.com/r/bkjaya1952/docker-zoneminder-master-mysql8

https://bkjaya.wordpress.com/2020/01/14/how-to-install-zoneminder-master-docker-v1-33-16-with-mysql-8-msmtp-on-ubuntu-19-10-eoan-ermine/

 

 

 

 

 

 

 

How to install Zoneminder-master- Docker , v1.33.16 with Mysql 8 ,MSMTP on Ubuntu 19.10 (Eoan Ermine)

In this tutorial ,we are going to use “Docker: Enterprise Container Platform”  (docker.io) on Ubuntu 19.10.

As , still there is on official  zoneminder issued for  Ubuntu 19.10 due dependency issues, the best option is to use docker Zoneminder  to overcome dependency problems and to avoid conflicts with the default setup of  Ubuntu 19.10

First

Installation of Docker on Ubuntu 19.10

On the Ubuntu terminal

sudo apt install docker.io

Then use , bkjaya1952/docker-zoneminder-master-mysql8 Docker Repository to make a container . ( This image has been created on ubuntu:eoan  with  zoneminder-master/ubuntu disco main)

I have created the above docker image and pushed to the Docker Hub.

Screenshot from 2020-01-14 23-43-41

Figure:- bkjaya1952/docker-zoneminder-master-mysql8:1.33.16 Repository at dockerhub

sudo docker create -t -p 8080:80 --shm-size=4096m --name zm --privileged=true bkjaya1952/docker-zoneminder-master-mysql8:1.33.16

sudo docker start zm

You will have to configure the running zm container for mysql 8 ,zm data base and make some changes to start apache and zoneminder during the first run .


sudo docker exec -t -i zm /bin/bash

# Now you will be with in the zm container.

Make changes as follows

/etc/init.d/mysql start

chown -R www-data:www-data /var/run/zm

sed -i "228i ServerName localhost" /etc/apache2/apache2.conf

 


# Making an empty root password

mysql

CREATE USER 'admin'@'localhost' IDENTIFIED WITH mysql_native_password BY '';

GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;

FLUSH PRIVILEGES ;

quit

mysqladmin -uroot -p reload

mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql

 

# Making zoneminder user and password


mysql

CREATE USER 'zmuser'@localhost IDENTIFIED WITH mysql_native_password BY 'zmpass';

GRANT ALL PRIVILEGES ON zm.* TO 'zmuser'@'localhost' WITH GRANT OPTION;

FLUSH PRIVILEGES ;

quit

mysqladmin -uroot -p reload

service apache2 start

service apache2 reload

exit

(As the apache service and zoneminder do not in running condition , when the zm container is started , we will have to edit the file “/etc/bash.bashrc” . )

(For editing , the “bash.bashrc” file is copied to the host and copied back to the container “zm” after making changes as follows. You will have to make these changes at the first time running only. )

(Open the Ubuntu terminal at the host)

 
 sudo docker cp zm:/etc/bash.bashrc ~/Downloads

( Here i have copied the file to the Downloads folder of the computer)

(If go the Downloads folder, you can see the copied “bash.bashrc” file) (In order to make changes to “bash.bashrc”)

sudo chmod -R 777 ~/Downloads/bash.bashrc
sudo gedit ~/Downloads/bash.bashrc

(Now enter the following two lines at the bottom of the opened “bash.bashrc” file and save.)

Screenshot from 2020-01-14 23-10-08

Figure:- Edited “bash.bashrc” file

/etc/init.d/apache2 start

/usr/bin/zmpkg.pl start

 

(To copy back the edited “bash.bashrc” to /etc/ of the container “zm” , run the following command on the terminal)

 

sudo docker cp ~/Downloads/bash.bashrc zm:/etc/

(Now you can restart the container to see whether the zoneminder is active as follows)

sudo docker restart zm

sudo docker exec -t -i zm /bin/bash

http://localhost:8080/zm/

Screenshot from 2020-01-14 18-25-27

Figure:- ZM-Console after adding IP Cam & USB Cam

Starting & stopping of the docker container “zm” and zoneminder can be done using script files as follows.Those script files are created using the text editor and saved in Document directory.

Starting process  consists  of two script files , namely zmdockerstart.sh and zmdostart.sh .

When the zmdostart.sh is executed , it redirects to  the core file zmdockerstart.sh , which

is having scripts to start ” zm ” container , and to start services apache and zoneninder. The command “docker exec -t -i am /bin/bash” starts the services apache aand zoneminder .

Note:- The script file “zmdockerstart.sh” alone can’t start services apache and zoneninder. Therefore, an additional  redirecting script file “zmdostart.sh” has to introduced.

Screenshot from 2020-01-16 11-04-45
Start script ( file zmdockerstart.sh)
Screenshot from 2020-01-16 11-04-15
Initiatating srater script ( file zmdostart.sh)

Figure:-2 Starting script files  zmdockerstart.sh & zmdostart.sh

 

Stopping script

 

Screenshot from 2020-01-15 22-54-27

Figure:-3 Stopping script file zmdockerstop.sh

 

 

Making files executable

sudo chmod +x ~/Documents/zmdockerstart.sh

sudo chmod +x ~/Documents/ zmdockerstop.sh

sudo chmod +x ~/Documents/ zmdostart.sh

The  sudo privileges have given to the above files using “sudo visudo ” on the Ubuntu terminal and adding the files in /etc/sudoers file as follows

sudo visudo

Screenshot from 2020-01-16 09-32-33

Figure:-4 Adding script file paths to /etc/sudoers.tmp ( to give sudo privileges to script files

Screenshot from 2020-01-16 11-05-30

Figure:-5 Stater buttons are created on the dock using Manmenu software

Screenshot from 2020-01-15 22-56-30

Figure:-6 Start  & Stop buttons on the Dock

 

(Note:- Each time , you start the container ,you will have to run ” sudo docker exec -t -i zm /bin/bash” after “sudo docker start zm” to get the ZM Console) (To use msmtp for emailing please refer https://hub.docker.com/repository/docker/bkjaya1952/docker-zoneminder-master)

The  details on composing the image can be get from the the following link

How to Build a Zoneminder-master Docker-Image with MYSQL 8 & MSMTP

 

How to uninstall the setup

How to uninstall the Docker container:-

On the Ubuntu terminal

sudo docker rm zm

How to uninstall the Repository :-

sudo docker rmi bkjaya1952/docker-zoneminder-master-mysql8:1.33.16

 

 


 

How to install Zoneminder-master- Docker , v1.33.16 with MSMTP on Ubuntu 19.10 (Eoan Ermine)

In this tutorial ,we are going to use “Docker: Enterprise Container Platform”  (docker.io) on Ubuntu 19.10.

As , still there is on official  zoneminder issued for  Ubuntu 19.10 due dependency issues, the best option is to use docker Zoneminder  to overcome dependency problems and to avoid conflicts with the default setup of  Ubuntu 19.10

First

Installation of Docker on Ubuntu 19.10

On the Ubuntu terminal

sudo apt install docker.io

Then use , bkjaya1952/docker-zoneminder-master  Docker Repository to make a container . ( This image has been created on Ubuntu 19.04 disco )

sudo docker create -t -p 8085:80 --shm-size=4096m -e TZ=Asia/Colombo --name myzm --privileged=true bkjaya1952/docker-zoneminder-master:v1.33.16.

Note :- use your timezone instead of “TZ=Asia/Colombo”

sudo docker start myzm

For configuring MSMTP for emailing zoneminder motion detection events, please refer the following link.

https://hub.docker.com/r/bkjaya1952/docker-zoneminder-master

Open http://localhost:8085/zm/ and add the camera monitors

And fill up email details under the Optons/email of the ZM-Panel

Create appropriate zm-filter to send email alerts of motion detection events

Screenshot from 2020-01-12 11-20-09

Figure:- 1 After adding Camera monitors to ZM

 

 

 


 

The scripts of the Dockerfile are as shown in the following figure

Screenshot from 2020-01-12 11-07-16

Figure:-2 The scripts of the Dockerfile

To download the Dockerfile  https://www.dropbox.com/s/737qnv3144b52bi/Dockerfile?dl=0

To download the entrypoint.sh https://www.dropbox.com/s/m5lgf2d196a4f5s/entrypoint.sh?dl=0

Please refer my following blog to know about the building an image and pushing to the Docker Hub

https://bkjaya.wordpress.com/2019/12/20/how-to-build-a-zoneminder-docker-image-with-msmtp-using-a-dockerfile-push-to-docker-hub-ubuntu-19-10/

Acknowledgements : Based on Zoneminder and Andrew Bauer’s zonexpertconsulting@outlook.com entrypoint script

How to install Zoneminder , ( v1.33.16.) with Mysql 8 on Ubuntu 19.10

Since the official Zoneminder eoan has Dependency wait on lgw01-amd64-051 , We will have to install Zoneminder disco  on Ubuntu 19.10.

There is a problem in the present PHP release which make errors with the “caching_sha2_password” introduced in the Mysql 8 by default .
Please refer the following link
https://www.php.net/manual/en/mysqli.requirements.php
Therefore , we will have to use “mysql_native_password” method in Mysql 8.

First of all we will have to install mysql-server-8 on Ubuntu 19.10 and enable mysql_native_password

The installation  of mysql-server-8.0 can be done using the synaptic package manager .

Screenshot from 2020-01-03 22-46-01

Figure:-1 Installed mysql-server-8 shown in synaptic package manager

Then open the Ubuntu terminal

sudo su

rm /etc/mysql/my.cnf
cp /etc/mysql/mysql.conf.d/mysqld.cnf /etc/mysql/my.cnf

gedit /etc/mysql/my.cnf

Then enter the following line below [mysqld] on the opened my.cnf file and save the file

[mysqld]

default_authentication_plugin= mysql_native_password

Screenshot from 2020-01-04 00-20-27

Figure:-2  Amended  /etc/mysql/my.cnf

Then on the Ubuntu terminal

systemctl restart mysql

Then enter the following commands on the terminal to set root password for mysql server

mysql 
CREATE USER 'admin'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your password';

GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;

FLUSH PRIVILEGES ;

quit

systemctl restart mysql

 

 

 

Then install Zoneminder

The Zoneminder disco deb file is downloaded from https://launchpad.net/~iconnor/+archive/ubuntu/zoneminder-master/+build/18492553/+files/zoneminder_1.33.16~20191229135312-disco_amd64.deb

GDebi Package Installer can be used to install the Zoneminder disco deb file

Before installing Zoneminder disco deb file to overcome dependency issues we will have to  download libmysqlclient20and install first  using the GDebi Package Installer.

Then install Zoneminder disco deb file that we have downloaded .

Creating user and zmpass

Open the Ubuntu terminal and enter  following 5 commands

sudo su

mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql

mysql


CREATE USER 'zmuser'@localhost IDENTIFIED WITH mysql_native_password BY 'zmpass';

GRANT ALL PRIVILEGES ON zm.* TO 'zmuser'@'localhost' WITH GRANT OPTION;

FLUSH PRIVILEGES ;

quit

mysqladmin -uroot -p reload

 

It was observed that there are missing *.ini files in /etc/php/7.3/mods-available/ which will make problems in getting zoneminder Console.

Therefore the necessary files have to be copied from /usr/share/php7.3-mysql/mysql

sudo cp /usr/share/php7.3-mysql/mysql/*.ini /etc/php/7.3/mods-available/

sudo service apache2 reload

 

Screenshot from 2020-01-03 22-17-43

Figure:-3  After coping mysql*.ini files from /usr/share/php7.3-mysql/mysql/

Screenshot from 2020-01-03 22-12-15

Figure:-4 mysql*.ini files in /usr/share/php7.3-mysql/mysql/

chmod 740 /etc/zm/zm.conf
chown root:www-data /etc/zm/zm.conf
adduser www-data video
a2enmod cgi
a2enconf zoneminder
a2enmod rewrite
chown -R www-data:www-data /usr/share/zoneminder/
systemctl enable zoneminder
service zoneminder start

 

Add timezone to PHP (  This step is not essential for Zoneminder 1.33 as you can change the TIMEZONE later under Options/System/TIMEZONE )

gedit /etc/php/7.3/apache2/php.ini
edit line 956 with your timezone
Then
sudo service apache2 reload

Open zoneminder web console (http://localhost/zm/)



Screenshot from 2020-01-03 22-31-41

Figure:-5 Zoneminder Console , after adding an Usb camera

(Note :-
In order to have  clean mysql-server-8.0 install , it is better to completely delete exiting mysql as follows 
sudo apt remove --purge mysql-server mysql-client mysql-common
sudo apt  autoremove
sudo apt autoclean 
 sudo rm -rf /etc/mysql )

How to select and copy a latest file from a folder to another folder- Ubuntu Script

Background:

Once , I had a requirement to find a method  to send email alerts with an attached video of the event ,when a motion detection is occurred in Motion Linux .

According to my configuration of camera4.conf , the video clips of motion detection events are stored automatically  in a folder (motion) at ~/Videos/motion of the computer.

  1. My target was to select most resent video clip in ~/Videos/motion and to send email alert attached  with the video clip.
  2. For the purpose of easy emailing purpose  I have decided to create a sub folder called “sub” under ~/Videos/motion ( ~/Videos/motion/sub) to copy selected the latest video clip in to it.
  3. Then an Ubuntu script file was prepared to do the above two steps

I have tried two methods in two alternative script files successfully ,where the details are appended below.

The script files were placed at ~/Documents folder of the computer

Method 1

Name of the file mewinu.sh

Scripts in mewinu.sh are listed below

#!/bin/bash
rm ~/Videos/motion/sub/*.*
i=0
j=$(stat ~/Videos/motion/*.mkv --printf "%i\n" | wc -l )
for k in ~/Videos/motion/*.mkv; do
  if (( (j - ++i) < 1 )); then
    cp -v -- "$k" ~/Videos/motion/sub
  fi
done
echo "See this vieo" | mutt -s "Motion is Detected" -a /home/bkjaya1952/Videos/motion/sub/*.mkv -- bkjaya1952@aol.com

 

Screenshot from 2019-12-23 17-30-06

Figure:- 1 scripts in mewinu.sh

For making mewinu.sh executable, on Ubuntu terminal , run

sudo chmod +x ~/Documents/mewinu.sh

When “mewinu.sh” is executed every time , first all the files at ~/Videos/motion/sub are deleted by the following command in mewinu.sh

rm ~/Videos/motion/sub/*.*

Then the latest video is selected from folder ~/Videos/motion and copy in to the folder ~/Videos/motion/sub by the following commands in mewinu.sh

i=0
j=$(stat ~/Videos/motion/*.mkv --printf "%i\n" | wc -l )
for k in ~/Videos/motion/*.mkv; do
  if (( (j - ++i) < 1 )); then
    cp -v -- "$k" ~/Videos/motion/sub
  fi
done

Then an email alert is sent with an attachment  of the latest video copied in to ~/Videos/motion/sub by the following command

echo "See this vieo" | mutt -s "Motion is Detected" -a /home/bkjaya1952/Videos/motion/sub/*.mkv -- bkjaya1952@aol.com

 

The most important commands for selecting and coping latest file to another folder in Method 1 is marked in red as shown above  .

 

Usage of Method 1 is described in the following link

How to Email Motion Detection videos of Motion Linux( 3.2.2) using Mutt on Ubuntu 19.04


 

Method 2

Name of the file MotionTest.sh

Scripts in MotionTest.sh are listed below

#!/bin/bash
rm ~/Videos/motion/sub/*.*
cp -p “`ls -dtr1 ~/Videos/motion/*.mkv | tail -1`” ~/Videos/motion/sub
rclone copy ~/Videos/motion/sub/*.mkv gdrv:camera

echo “web link of the folder where the videos where videos are  stored in drivehq.com  ” | mutt -s “Motion is detected see the link” — bkjaya1952@aol.com

 

Screenshot from 2019-12-23 18-51-05

Figure:- 2  scripts in MotionTest.sh

For making MotionTest.sh executable, on Ubuntu terminal , run

sudo chmod +x ~/Documents/mewinu.sh

 

Then the latest video is selected from folder ~/Videos/motion and copy in to the folder ~/Videos/motion/sub by the following command in MotionTest.sh

cp -p "`ls -dtr1 ~/Videos/motion/*.mkv | tail -1`" ~/Videos/motion/sub

 

The most important commands for selecting and coping latest file to another folder in Method 2  is marked in green  as shown above  .

Then the latest video is uploaded to free ftp cloud DriveHQ (named as gdrv in rclone)using the rclone  software.

And then, an  email alert is sent with an attachment  of the link of the the latest video uploaded to gdrv  by the following command .

echo "web link of the folder where the videos where videos are  stored in drivehq.com  " | mutt -s "Motion is detected see the link" -- bkjaya1952@aol.com
Usage of Method 1 is described in the following link 

https://bkjaya.wordpress.com/2019/07/29/how-to-auto-upload-motion-detection-videos-of-motion-linux-to-free-ftp-server-drivehq-using-rclone-and-get-email-alerts-on-ubuntu-19-04/

How to Build a Zoneminder Docker Image (with MSMTP) using a Dockerfile & push to Docker Hub , (Ubuntu 19.10)

 

In this tutorial ,we are going to use “Docker: Enterprise Container Platform”  (docker.io) on Ubuntu 19.10.

First

Installation of Docker on Ubuntu 19.10

On the Ubuntu terminal

sudo apt install docker.io

Then a zoneminder-docker image is built using a Dockerfile and entrypoint.sh

Dockerfile contains the scripts to install free open-source  software Zoneminder and entrypoint.sh has necessary commands to start Zoneminder ,Apache and other services and to keep the docker container running.

I have used my own  Dockerfile and entrypoint.sh prepared  by Andrew Bauer

The scripts in the Docker file are as shown in the following figure:- 1

Screenshot from 2019-12-20 09-57-44

Figure:- 1 Scripts in the Dockerfile

 

 

For the purpose of building the zoneminder- docker image the files Dockerfile and entrypoint.sh are saved on the Documents  folder of the computer as shown in the following figure:- 2.

Screenshot from 2019-12-20 10-05-13

figure:- 2 Dockerfile and entrypoint.sh  marked in green color saved in the Documents folder

The Dockerfile and entrypoint.sh can be downloaded from this links

 

Dockerfile

entrypoint.sh

 

Building the Zoneminder-Docker image ( tagged as “yourzoneminder”)

Open the Ubuntu terminal

cd ~/Documents
docker build --tag=yourzoneminder . # Dockerfile

sudo docker build –tag=yourzoneminder . # Dockerfile

( The process will take about 10-15 minutes)

After the image building process is finished ,you find the image by runng

sudo docker images

 

For the purpose of  identifying the image in the Docker Hub , you will have to tag it with an appropriate name .

In our case ,I have name as “bkjaya1952/docker-zoneminder:v1.32.3.”

 

sudo docker tag yourzoneminder bkjaya1952/docker-zoneminder:v1.32.3.

 

Then push the tagged image to the Docker Hub

sudo docker login

Note : first you will have to signup & open  a Docker Hub account at https://hub.docker.com/

sudo docker push bkjaya1952/docker-zoneminder:v1.32.3.

Screenshot from 2019-12-19 23-45-44

Screenshot from 2019-12-19 23-47-07

Figure:- 3  Tagging and pushing the image to the Docker Hub

Now you can see my pushed image at  https://hub.docker.com/repository/docker/bkjaya1952/docker-zoneminder

Screenshot from 2019-12-20 10-55-21

Figure:-  4 Pushed image at the Docker Hub

The instructions to use the image has been entered at the Docker Hub, after the pushing is completed .

 

Usage of the pushed image  bkjaya1952/docker-zoneminder

 

sudo docker create -t -p 8085:80 --shm-size=4096m -e TZ=Asia/Colombo --name myzm --privileged=true bkjaya1952/docker-zoneminder:v1.32.3.

Note :- use your timezone instead of “TZ=Asia/Colombo”

sudo docker start myzm

Configuring MSMTP for emailing zoneminder motion detection events

Make the following file in the home folder of your computer and copy in to the zm container that you have created by above mentioned commands

Open the Ubuntu terminal and run

sudo gedit msmtprc

Then copy the following scripts with modifications to suit your gmail address and save


# Set default values for all following accounts.
defaults
auth on
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile ~/.msmtp.log

# Gmail
account gmail
host smtp.gmail.com
port 587
from youer gmail address
user youer gmail address
password your gmail password

# Set a default account
account default : gmail


Then copy the created msmtpru file to the folder /etc/ of the zm container as follows

sudo docker cp msmtprc myzm:/etc/msmtprc

Open http://localhost:8085/zm/ and add the camera monitors

Screenshot from 2019-12-20 11-16-51

Figure:- 5 Added USB camera to Zoneminder

And fill up email details under the Optons/email of the ZM-Panel

Create appropriate zm-filter to send email alerts of motion detection events

For entering e mail details and creating  zm-filter  please refer my following blog ( After the Figure:- 3 in the blog)

How to install Zoneminder 1.32 (with MSMTP email support ) in Docker on Ubuntu 19.10

 

 

Screenshot from 2019-12-20 11-19-39

Figure:- 5 Received motion detection email alerts from Zoneminder

Acknowledgements : Based on Isaac Connor’s   Zoneminder and Andrew Bauer’s zonexpertconsulting@outlook.com entrypoint script

at https://raw.githubusercontent.com/ZoneMinder/zmdockerfiles/master/utils/entrypoint.sh

 

 

 

 

 

 

 

 

 

 

 

 

How to install Zoneminder 1.32 (with MSMTP email support ) in Docker on Ubuntu 19.10

In this tutorial ,we are going to use “Docker: Enterprise Container Platform”  (docker.io) to install “bkjaya1952/zoneminder” on Ubuntu 19.10 operating system. The “bkjaya1952/zoneminder” which  is based on  zoneminder master packages has been maintained and uploaded to the Docker Hub by me.

 

(My Repository  “bkjaya1952/zoneminder” is based on “quantumobject/docker-zoneminder” created by Angel Rodriguez-Rodiguez-Riccrdo.  I have created a zoneminder image using quantumobject/docker-zoneminder  and edited to incorporate MSMTP  ,then uploaded to the Docker hub)

Installation of Docker on Ubuntu 19.10

On the Ubuntu terminal

sudo apt install docker.io

Then create network

sudo docker network create net

Then install db  and zm using mysql/mysql-server:5.7 and  bkjaya1952/zoneminder

sudo docker run -d -e TZ=Asia/Colombo -e MYSQL_USER=zmuser -e MYSQL_PASSWORD=zmpass -e MYSQL_DATABASE=zm -e MYSQL_ROOT_PASSWORD=mysqlpsswd -e MYSQL_ROOT_HOST=% --net net --name db mysql/mysql-server:5.7

 

sudo docker run -d --shm-size=4096m -e TZ=Asia/Colombo -e ZM_DB_HOST=db --net net --name zm --privileged=true -p 8080:80 bkjaya1952/zoneminder

Sudo docker start db zm

Configuring MSMTP to suit your email

Create MSMTP configuration file msmtprc in your Home directory of your computer as follows and copy it to /etc/ sub directory of the “zm” docker container that you have created by above mentioned command .

On the Ubuntu terminal

sudo gedit msmtprc

Copy the following scripts with modifications to suit your gmail address in to the opened mamtprc emty file and save

# Set default values for all following accounts.
defaults
auth on
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile ~/.msmtp.log

# Gmail
account gmail
host smtp.gmail.com
port 587
from youer gmail address
user youer gmail address
password your gmail password

# Set a default account
account default : gmail

Screenshot from 2019-12-16 18-50-54

Figure:- 1 scripts in mamtprc

 

Then copy msmtprc file to zm:/etc/   (to the zm docker container)

sudo docker cp msmtprc zm:/etc/msmtprc

Open http://localhost:8080/zm/ and add the camera monitors

Screenshot from 2019-12-16 08-51-53

Figure:- 2  ZM-Console

 

Screenshot from 2019-12-16 08-57-26.png

Figure:-  3  After adding USB Camera

And fill up email details under the Optons/email of the ZM-Panel

Screenshot from 2019-12-16 08-53-01

Figure:-  4 Entering email details

Please note the following additional entries under EMAIL_BODY cage

Alarmed event image : %EI1%
Alarmed video : %EV%

 

Screenshot from 2019-12-16 08-53-47

Figure:-  5 Entering email details continued

Please note

URL is localhost:8080/zm

SSMTP_PATH is  /usr/bin/msmtp

Creating zm-filter to initiate emails

Screenshot from 2019-12-16 08-54-22

Figure:- 6  zm-filter

Screenshot from 2019-12-16 19-19-36

Figure:-  7 Received email alerts

 

 

Acknowledgements : Based on Zoneminder and quantumobject/docker-zoneminder