ZoneMinder / zmdockerfiles

Dockerfiles for the ZoneMinder project build system and for running ZoneMinder
210 stars 106 forks source link

Cannot connect to external database #73

Closed sysoppl closed 2 years ago

sysoppl commented 3 years ago

I tried to create docker with external database, but it's not working. I have several other dockers connected to my database, so it is not my db fault. Also, I checked credentials three times .

Used dockerfile: zoneminderhq/zoneminder:latest-ubuntu18.04 Logs:

 * Remote database credentials detected. Continuing...
 * Looking for remote database server   ...failed!
 * Starting Apache http web server service   ...done.
 * Starting ZoneMinder video surveillance recorder   ...failed!

I tried IP:PORT and DOMAIN:PORT My port is different than 3306

sudo docker create --name "zoneminder" -t -p 1234:80 \
    -e TZ='Europe/Warsaw' \
    -e ZM_DB_USER='USER' \
    -e ZM_DB_PASS='PW' \
    -e ZM_DB_NAME='DB' \
    -e ZM_DB_HOST='IP:PORT' \
    -v /xxx/events:/var/cache/zoneminder/events \
    -v /xxx/images:/var/cache/zoneminder/images \
    -v /xxx/zoneminder/logs:/var/log/zm \
    --shm-size="6144m" \
    zoneminderhq/zoneminder:latest-ubuntu18.04

This seems similar to https://github.com/ZoneMinder/zmdockerfiles/issues/62

vince122 commented 3 years ago

Same here.. Not been able to run this docker file with MYSQL port different from 3306 (Synology)

panzerlinux commented 3 years ago

Can't connect to any external DB on Centos latest. Failed connecting to existing and deployed a dedicated DB with non standard port on k3s/ubuntu. Thank you

VasoVV commented 3 years ago

I make it works by manually creating ZoneMinder database (full database with all tables) on remote MySQL server. In spite of getting error * Looking for remote database server ...failed! when container starts.

sysoppl commented 3 years ago

@VasoVV can you provide URL with database to import?

winflo commented 2 years ago

Same Problem here. I used https://github.com/ZoneMinder/zoneminder/blob/master/db/zm_create.sql.in which solved my problem.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stephen304 commented 2 years ago

I ran into this issue and discovered that the zm_db_exists method at https://github.com/ZoneMinder/zmdockerfiles/blob/master/utils/entrypoint.sh#L202= falsely thinks that the DB is already initialized since it only checks if the DB exists, and when using an external DB with docker, usually the DB is initialized by the DB container without any tables. So I just changed it to check for the Config table so it will correctly determine that the DB hasn't been initialized.

        mysqlshow -u${ZM_DB_USER} -p${ZM_DB_PASS} -h${ZM_DB_HOST} ${ZM_DB_NAME} | grep "Config" > /dev/null 2>&1

And mounted that over the existing entry script: - ./entrypoint.sh:/usr/local/bin/entrypoint.sh

Once I changed that, I also realized that it doesn't support using a DB named other than "zm", I'm assuming the setup script just hardcodes that in. Since that script isn't in this repo I didn't bother trying to fix it and instead I just used DB name and user zm/zm to make things simpler.

OdinVex commented 3 months ago

This issue should not be closed, it still exists. The error-handling should also be updated to explain that it could connect to the database server but the database itself isn't found.

Edit: It also doesn't seem to support PORTS. -P is the parameter for ports, using any port or colon in the HOST name will cause it to never find the host. So many assumptions around accessing the server... X_x