Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

https://hub.docker.com/r/dlandon/zoneminder/

https://github.com/dlandon/zoneminder

https://zoneminder.readthedocs.io/en/latest/installationguide/easydocker.html

Create Image and confirm access to GUI:

Docker Run:

WD=/opt/zoneminder
mkdir -p $WD/{mnt,setup,conf,data}
cd $WD/setup
cat << 'EOF' >zoneminder_docker.sh
#!/bin/bash

docker run -d --name="zoneminder" \
--net="bridge" \
--privileged="true" \
-p 8443:443/tcp \
-p 9000:9000/tcp \
-e TZ="America/Whitehorse" \
-v "/opt/zoneminder/conf":"/config" \
-v "/opt/zoneminder/data":"/var/cache/zoneminder" \
-v "/opt/zoneminder/mnt":"/mnt" \
-v "/etc/ssl":"/etc/apache2/ssl" \
dlandon/zoneminder
EOF

Docker-Compose:


WD=/opt/zoneminder
mkdir -p $WD/{mnt,setup}
cd $WD/setup
cat << 'EOF' >docker-compose.yaml
version: '3.7'

services:
 zoneminder:
    container_name: zoneminder
    hostname: zoneminder
    image: dlandon/zoneminder
    network_mode: bridge
    privileged: true
    ports:
      - '8443:443'
      - '9000:9000'
    volumes:
      - type: bind
        source: /opt/zoneminder/conf/
        target: /config
      - type: bind
        source: /opt/zoneminder/data/
        target: /var/cache/zoneminder
      - type: bind
        source: /etc/ssl
        target: /etc/apache2/ssl
      - type: bind
        source: /opt/zoneminder/mnt/
        target: /mnt
    environment:
      - 'TZ=America/Whitehorse'


EOF
chmod +x docker-compose.yaml


ZMCLI Alias:

echo 'alias zmcli="docker exec -it zoneminder /bin/bash"' >> ~/.bashrc
source ~/.bashrc

Fix SSL:

Note: You should use zmcli in another terminal session.

zmcli
apt update 
apt install nano
nano /etc/apache2/sites-enabled/default-ssl.conf


                SSLCertificateFile      /etc/apache2/ssl/certs/zoneminder.crt
                SSLCertificateKeyFile /etc/apache2/ssl/private/zoneminder.key
                SSLCACertificateFile /etc/apache2/ssl/certs/zm-ca-bundle.crt


service apache2 restart

NginX Config:

##GLOBAL SSL
ssl_certificate /etc/apache2/ssl/certs/zoneminder.crt;
ssl_certificate_key /etc/apache2/ssl/private/zoneminder.key;

##ZoneMinder
server {
       listen         80;
       server_name    sub.domain.tld;

       return         301 https://$server_name/;

}

server {
        listen 443 ssl;
        server_name sub.domain.tld;

location / {

        proxy_pass              https://localhost:8443/;
        include                 /etc/nginx/proxy.conf;
    }
}

Autostart & Daemonize:

Docker-Run:

cat << 'EOF' >$WD/setup/zoneminder.service.setup.sh
cat << 'EOL' >/lib/systemd/system/zoneminder.service
[Unit]
Description=ZoneMinder_Docker_Container
Requires=docker.service network-online.target

[Service]
Restart=on-abnormal
ExecStart=/usr/bin/docker start -a zoneminder
ExecStop=/usr/bin/docker stop -t 2 zoneminder

[Install]
WantedBy=multi-user.target
EOL
systemctl enable zoneminder
systemctl restart zoneminder
systemctl status zoneminder
EOF
chmod +x $WD/setup/zoneminder.service.setup.sh

Docker-Compose:


WD=/opt/zoneminder/setup
cat << EOF >$WD/zoneminder.service.setup.sh
cat << EOL >/lib/systemd/system/zoneminder.service
[Unit]
Description=zoneminder_Docker
Requires=docker.service network-online.target

[Service]

Restart=on-abnormal
ExecStart=/usr/bin/docker-compose --project-name zoneminder --project-directory $WD -f $WD/docker-compose.yaml up
ExecStop=/usr/bin/docker-compose --project-name zoneminder --project-directory $WD -f $WD/docker-compose.yaml stop

[Install]
WantedBy=multi-user.target
EOL
systemctl enable zoneminder
systemctl start zoneminder
EOF
chmod +x $WD/zoneminder.service.setup.sh
$WD/zoneminder.service.setup.sh


Note: To get e-mail to work, I setup a postfix relay server in another docker container and used that to send e-mails. Note: when using IP, use your host IP (it's static right?!), not the docker container IP. I have my relay setup that port 25 is mapped on the host so it all works regardless.



  • No labels