For security reasons, the ZM database user zoneminder-docker_rw is unique to this docker image and only has access to this one database. This was set beforehand in my networked sql server.
Caveat: I needed to create the ZoneMinder database in advance. Like others, this was a stumbling block. To solve this problem, I got ZM running without my external sql server. Once running, I ran mysqldump to export the basic ZM database structure. I imported this dump into my networked mysql server, and voila...the following configuration will work. I also needed to set the TZ in the mysql docker container otherwise ZM would complain about a misconfiguration during initialization.
Code: Select all
# Creates mysql container and phpMyAdmin service to manage it
# Video at https://www.youtube.com/watch?v=NdwB5TPXCnQ explains the file
networks:
# This will create a user-defined network with name of mysql-net
# Specify name so that it does not append stack name and become db_mysql-net
mysql-net:
name: mysql-net
driver: bridge
volumes:
# Creates persistent storage volume for database
# Specify name so it does not append stack name in front
mysqldata:
driver: local
name: mysql
driver_opts:
type: 'none'
o: 'bind'
device: '/raid/www-docker/mysql'
services:
mysql:
image: mysql:latest
container_name: mysql
hostname: mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: ********
TZ: America/Los_Angeles
ports:
- "6033:3306"
volumes:
# Will use db volume and inside to path /var/lib/mysql
- mysqldata:/var/lib/mysql
- /raid/rcollins/tmp:/raid/rcollins/tmp
networks:
- mysql-net
# Install phpmyadmin to help administer mysql
phpmyadmin:
# Depends on only works within same stack, but not between remote containers (even on user-defined network)
depends_on:
- mysql
image: phpmyadmin/phpmyadmin
restart: always
networks:
- mysql-net
container_name: phpmyadmin
hostname: phpmyadmin
ports:
# Exposes external port 7000 mapped to internal of 80
# Database required no external port of its own
- 7000:80
environment:
PMA_HOST: mysql
PMA_PORT: 3306
MYSQL_ROOT_PASSWORD: ********
# Variable to increase upload limit for importing sql db files
UPLOAD_LIMIT: 200000K
zoneminder:
depends_on:
- mysql
container_name: zoneminder
image: zoneminderhq/zoneminder:latest-ubuntu18.04
restart: always
networks:
- mysql-net
ports:
# Exposes external port 9010 mapped to internal of 80
# Database required no external port of its own
- 9010:80
privileged: true
shm_size: 512M
environment:
ZM_DB_HOST: mysql
ZM_DB_USER: zoneminder-docker_rw
ZM_DB_NAME: ZoneMinder
ZM_DB_PASS: ********
ZM_TIMEZONE: America/Los_Angeles
TZ: America/Los_Angeles
volumes:
- /raid/www-docker/ZoneMinder/events:/var/cache/zoneminder/events
- /raid/www-docker/ZoneMinder/images:/var/cache/zoneminder/images
- mysqldata:/var/lib/mysql
- /raid/www-docker/ZoneMinder/logs:/var/log/zm