Docker support and some tips

Support for the docker image maintained by dlandon
Post Reply
dlandon
Posts: 14
Joined: Fri Oct 12, 2018 12:49 am

Docker support and some tips

Post by dlandon » Thu Feb 27, 2020 11:33 pm

This forum is for support of the dlandon Zoneminder docker. Please post questions and issues here and try to provide as much information as you can about your issue. Include informatuon about yout host system. I will try to post some solutions for some common issues.

There are several common issues with running this docker.
  • Be sure the volume mappings map to host system folders that exist and have r/w permission.
  • Be sre you have the correct port mappings for your system and there are no port conflicts.
  • You can update Zoneminder by just restarting the docker. The docker wil automatically update Zoneminder to the latest version.
  • To update the docker you need to remove the docker image and re-install it.
  • Remember that this is a Docker and has it's own Linux (Ubuntu 18.04). Zoneminder is installed in the Docker and not in the host system.
  • To get to the docker bash command line enter 'docker exec -i -t Zoneminder bash'

mnl1121
Posts: 1
Joined: Wed Apr 15, 2020 5:36 am

Re: Docker support and some tips

Post by mnl1121 » Wed Apr 15, 2020 6:10 am

Hi dlandon,

First thank you for taking the time to create a Docker image of ZoneMinder! I'm trying to migrate from the non-dockerized Zoneminder to dockerized. As a Docker amateur and having not had to mess with Docker in probably a year or so I'm having a bit of trouble getting Zoneminder going.

Trouble I'm having is ZoneMinder container starts and then shuts down. So two things that might be related and are contributing to this not working. First is I already have Portainer container using port 9000, so I changed to 9002 (also have something running on 9001). Second is the below error is why the container is shutting down. Does MariaDB need to be installed via another container or is it all self contained in the ZoneMinder container? My guess is it's self contained and changing the port is the issue. Any ideas?

Code: Select all

Starting services...,
 * Starting MariaDB database server mysqld,
   ...fail!,
DBI connect('database=zm;host=localhost','zmuser',...) failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) at /usr/share/perl5/ZoneMinder/Database.pm line 110.,
DBI connect('database=zm;host=localhost','zmuser',...) failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) at /usr/share/perl5/ZoneMinder/Database.pm line 110.,
DBI connect('database=zm;host=localhost','zmuser',...) failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) at /usr/share/perl5/ZoneMinder/Database.pm line 110.,
Apr 15 01:35:25 dde7ab623602 zmupdate[1012]: ERR [Error reconnecting to db: errstr:Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) error val:],
Can't call method "prepare_cached" on an undefined value at /usr/share/perl5/ZoneMinder/Config.pm line 96.,
BEGIN failed--compilation aborted at /usr/share/perl5/ZoneMinder/Config.pm line 147.,
Compilation failed in require at /usr/bin/zmupdate.pl line 73.,
BEGIN failed--compilation aborted at /usr/bin/zmupdate.pl line 73.,
Apr 15 01:35:25 dde7ab623602 zmupdate[1012]: ERR [Error reconnecting to db: errstr:Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) error val:],
DBI connect('database=zm;host=localhost','zmuser',...) failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) at /usr/share/perl5/ZoneMinder/Database.pm line 110.,
DBI connect('database=zm;host=localhost','zmuser',...) failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) at /usr/share/perl5/ZoneMinder/Database.pm line 110.,
DBI connect('database=zm;host=localhost','zmuser',...) failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) at /usr/share/perl5/ZoneMinder/Database.pm line 110.,
Apr 15 01:35:25 dde7ab623602 zmupdate[1014]: ERR [Error reconnecting to db: errstr:Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) error val:],
Can't call method "prepare_cached" on an undefined value at /usr/share/perl5/ZoneMinder/Config.pm line 96.,
BEGIN failed--compilation aborted at /usr/share/perl5/ZoneMinder/Config.pm line 147.,
Compilation failed in require at /usr/bin/zmupdate.pl line 73.,
BEGIN failed--compilation aborted at /usr/bin/zmupdate.pl line 73.,
Apr 15 01:35:25 dde7ab623602 zmupdate[1014]: ERR [Error reconnecting to db: errstr:Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) error val:],
 * Starting Apache httpd web server apache2,
 * ,
Starting ZoneMinder:,
DBI connect('database=zm;host=localhost','zmuser',...) failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) at /usr/share/perl5/ZoneMinder/Database.pm line 110.,
DBI connect('database=zm;host=localhost','zmuser',...) failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) at /usr/share/perl5/ZoneMinder/Database.pm line 110.,
Apr 15 01:35:27 dde7ab623602 zmpkg[1050]: ERR [Error reconnecting to db: errstr:Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) error val:],
DBI connect('database=zm;host=localhost','zmuser',...) failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) at /usr/share/perl5/ZoneMinder/Database.pm line 110.,
Can't call method "prepare_cached" on an undefined value at /usr/share/perl5/ZoneMinder/Config.pm line 96.,
BEGIN failed--compilation aborted at /usr/share/perl5/ZoneMinder/Config.pm line 147.,
Compilation failed in require at /usr/share/perl5/ZoneMinder.pm line 33.,
BEGIN failed--compilation aborted at /usr/share/perl5/ZoneMinder.pm line 33.,
Compilation failed in require at /usr/bin/zmpkg.pl line 34.,
BEGIN failed--compilation aborted at /usr/bin/zmpkg.pl line 34.,
Apr 15 01:35:27 dde7ab623602 zmpkg[1050]: ERR [Error reconnecting to db: errstr:Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) error val:],
neMinder failed to start,
,
*** /etc/my_init.d/40_firstrun.sh failed with status 255,
,
*** Killing all processes...,
Apr 15 01:35:27 dde7ab623602 syslog-ng[16]: syslog-ng shutting down; version='3.13.2',

UpDryTwist
Posts: 1
Joined: Sat Apr 25, 2020 10:43 pm

Re: Docker support and some tips

Post by UpDryTwist » Sun Apr 26, 2020 2:09 pm

Can't prove that this is your problem, but I was having a lot of problems getting the MySQL server up and running. It seemed to be a permissions problem ... but my permissions all seemed to be OK. Here's what I did to solve it:
1) You want to be able to view the log files from your docker image after it's quit out. To do so, commit a new version with a new entry-point so that you can start it up with a bash shell:
- docker ps -a to find your image
- docker commit {container id from above} yourname/test
- docker run -it --entrypoint=bash ...all the params you set originally... yourname/test
- that'll give you a shell in the image.

2) Once you're in, check /var/log/mysql/error.log for the last run (or for simplicity, delete error.log, and then re-run mysql with "service start mysql", to get a clean error log). If you see a warning that you can't write to the directory ... you have a permissions problem

3) Now to solve your problem.
0) I assume it's not a basic permissions problem -- but just in case, check all the permissions around that path.
a) If you put your data directory in an unusual place (/home, /usr, etc.) then you may have a problem with MariaDB itself deciding not to write. Look up ProtectHome and ProtectSystem settings (Google it). But really, it's easier to move the directory as otherwise you'll need to be patching the docker.
b) (this is what my problem was) On the host system, you may have a problem with SELinux or AppArmor (my problem) protecting that location. Good guides to fixing are here for SELinux (https://blogs.oracle.com/jsmyth/selinux-and-mysql) and here for AppArmor (https://blogs.oracle.com/jsmyth/apparmor-and-mysql) (in brief for the latter, need to add some lines at the end of the AppArmor config for mysql in the host.

User avatar
bkjaya1952
Posts: 195
Joined: Sat Aug 25, 2018 3:24 pm
Location: Sri Lanka
Contact:

Re: Docker support and some tips

Post by bkjaya1952 » Tue May 19, 2020 10:31 am

Sorry for the mistake. I have deleted the post
Last edited by bkjaya1952 on Sun Jul 19, 2020 5:05 pm, edited 1 time in total.

User avatar
asker
Posts: 1471
Joined: Sun Mar 01, 2015 12:12 pm

Re: Docker support and some tips

Post by asker » Wed May 20, 2020 11:35 am

@bkjaya1962, this forum is only meant for the (now official) docker image built by dlandon. It is not a general docker discussion forum for ZM. Please feel free to post your efforts in the ZM 1.3x forums
Please don't ask me questions via PM. Feel free to post in the forums or Github

My collection of ZoneMinder learnings:
https://wiki.zoneminder.com/Various_ZM_thoughts

Dax
Posts: 3
Joined: Wed Jan 22, 2020 9:24 am

Re: Docker support and some tips

Post by Dax » Wed Jun 10, 2020 8:43 am

Sorry for my english but I'm using google translate.

Hi, I have been using your image for a few months and it works very well, thank you for your work.
My problem is with letsencryp:
I mount in the container

Code: Select all

-v "/var/lib/docker/volumes/letsencrypt/appdata/config/etc/letsencrypt": "/le-ssl":ro
I copy the keys

Code: Select all

cp /le-ssl/live/xxx.duckdns.org/fullchain.pem /config/keys/cert.crt
cp /le-ssl/live/xxx.duckdns.org/privkey.pem /config/keys/cert.key
and edit the ServerName file.
Everything works, but I would like to use the certificates directly, so automatic certificate updating also works.
Is it possible to do this?

antleg9
Posts: 1
Joined: Fri Jul 03, 2020 8:00 am

Re: Docker support and some tips - struggling with mysql errors

Post by antleg9 » Fri Jul 03, 2020 8:16 am

Hello,
I am getting the dreaded :

Code: Select all

Starting services...
 * Starting MariaDB database server mysqld
   ...fail!
DBI connect('database=zm;host=localhost','zmuser',...) failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) at /usr/share/perl5/ZoneMinder/Database.pm line 110.
It does not seem to matter what I do with permissions of the host directories that get mounted and I have tried everything. Actually I get this error even when no host directories are mounted at runtime which leads me to believe that isn't the problem.

I've tried:
  • moving the host directory to different locations on the host
    ensuring that the host directory is group writable - actually even 777 didn't change the outcome
    configuring apparmor to allow mysql to write to this directory on the host
    using a docker volume rather than a directory on the host
    mounting nothing to the running container
I get the same error no matter what. I'm running Ubuntu 20.04 LTS, Docker version 18.06.1-ce, build e68fc7a. I pulled the image from docker hub and also built it myself from the git repo. Same outcome.

I need guidance as to what I might be doing wrong. I feel that getting mysql up and running is not the most complicated part of this install ( which I've slogged through myself before ) - so I must be missing something.

pollekepol
Posts: 1
Joined: Sat Jul 04, 2020 7:13 pm

Re: Docker support and some tips - struggling with mysql errors

Post by pollekepol » Sat Jul 04, 2020 7:18 pm

antleg9 wrote:
Fri Jul 03, 2020 8:16 am
Hello,
I am getting the dreaded :

Code: Select all

Starting services...
 * Starting MariaDB database server mysqld
   ...fail!
DBI connect('database=zm;host=localhost','zmuser',...) failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) at /usr/share/perl5/ZoneMinder/Database.pm line 110.
It does not seem to matter what I do with permissions of the host directories that get mounted and I have tried everything. Actually I get this error even when no host directories are mounted at runtime which leads me to believe that isn't the problem.

I've tried:
  • moving the host directory to different locations on the host
    ensuring that the host directory is group writable - actually even 777 didn't change the outcome
    configuring apparmor to allow mysql to write to this directory on the host
    using a docker volume rather than a directory on the host
    mounting nothing to the running container
I get the same error no matter what. I'm running Ubuntu 20.04 LTS, Docker version 18.06.1-ce, build e68fc7a. I pulled the image from docker hub and also built it myself from the git repo. Same outcome.

I need guidance as to what I might be doing wrong. I feel that getting mysql up and running is not the most complicated part of this install ( which I've slogged through myself before ) - so I must be missing something.
Same here unfortunately. Have been using this docker image a year ago with no probs on this same machine, but decided to use something else than zoneminder. Today I decided to go back to zoneminder, using again dlandon's image but running into the exact same problem as antleg9. Also on Ubuntu 20.04 LTS, using Docker version 19.03.12.

host folders exist and correctly mapped.
mysql folder in image owned by mysql, grp mysql; on host system the mysql folder is owned by "messagebus:syslog".

Sounds exactly like: https://github.com/dlandon/zoneminder/issues/19

User avatar
bkjaya1952
Posts: 195
Joined: Sat Aug 25, 2018 3:24 pm
Location: Sri Lanka
Contact:

Re: Docker support and some tips

Post by bkjaya1952 » Sun Jul 19, 2020 5:04 pm

asker wrote:
Wed May 20, 2020 11:35 am
@bkjaya1962, this forum is only meant for the (now official) docker image built by dlandon. It is not a general docker discussion forum for ZM. Please feel free to post your efforts in the ZM 1.3x forums
Hi Asker
Sorry for the mistake. I have deleted the post and re posted as per your instructions.
Best Regards
Thank you

saunders.rg
Posts: 3
Joined: Fri Jul 20, 2018 5:17 am

Re: Docker support and some tips - struggling with mysql errors

Post by saunders.rg » Sat Dec 05, 2020 8:13 am

After much trawling I came right with disabling AppArmor's MySQL profile - as per these posts:

viewtopic.php?f=41&t=29509&p=118942#p118942
https://mariadb.com/kb/en/the-community ... -when-try/
pollekepol wrote:
Sat Jul 04, 2020 7:18 pm
antleg9 wrote:
Fri Jul 03, 2020 8:16 am
Hello,
I am getting the dreaded :

Code: Select all

Starting services...
 * Starting MariaDB database server mysqld
   ...fail!
DBI connect('database=zm;host=localhost','zmuser',...) failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) at /usr/share/perl5/ZoneMinder/Database.pm line 110.
It does not seem to matter what I do with permissions of the host directories that get mounted and I have tried everything. Actually I get this error even when no host directories are mounted at runtime which leads me to believe that isn't the problem.

I've tried:
  • moving the host directory to different locations on the host
    ensuring that the host directory is group writable - actually even 777 didn't change the outcome
    configuring apparmor to allow mysql to write to this directory on the host
    using a docker volume rather than a directory on the host
    mounting nothing to the running container
I get the same error no matter what. I'm running Ubuntu 20.04 LTS, Docker version 18.06.1-ce, build e68fc7a. I pulled the image from docker hub and also built it myself from the git repo. Same outcome.

I need guidance as to what I might be doing wrong. I feel that getting mysql up and running is not the most complicated part of this install ( which I've slogged through myself before ) - so I must be missing something.
Same here unfortunately. Have been using this docker image a year ago with no probs on this same machine, but decided to use something else than zoneminder. Today I decided to go back to zoneminder, using again dlandon's image but running into the exact same problem as antleg9. Also on Ubuntu 20.04 LTS, using Docker version 19.03.12.

host folders exist and correctly mapped.
mysql folder in image owned by mysql, grp mysql; on host system the mysql folder is owned by "messagebus:syslog".

Sounds exactly like: https://github.com/dlandon/zoneminder/issues/19

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests