juanluisbaptiste / docker-otrs

The unofficial Znuny/OTRS Ticketing System docker image
https://www.juanbaptiste.tech/category/otrs
GNU Lesser General Public License v3.0
173 stars 101 forks source link

external database #1

Closed 0x9394 closed 9 years ago

0x9394 commented 9 years ago

is it able to use external database? (standalone, not docker) thanks.

juanluisbaptiste commented 9 years ago

Theoretically yes, I designed it to be able to be run like that. When the otrs container boots it will check if there's already an 'otrs' database and if true then it will use that one instead of loading a default sql file or a backup, unless OTRS_DROP_DATABASE="yes", in that case if the database exists it will be dropped and recreated and loaded by the otrs container.

The other issue is the database host, currently the database container name is hardcoded as 'mariadb'. You have two options here: you could add a custom host entry to the otrs container using when running it using extra_hosts: on the docker-compose.yml file:

extra_hosts:
- "mariadb: 1.2.3.4"

were 1.2.3.4 is the external db IP address. The other option would be to modify the code to check for new environment variables like OTRS_DB_SERVER, OTRS_DB_PORT and if they are set, use those instead of the harcoded mariadb container name (Take a look at run.sh and functions.sh). PR welcome :)

0x9394 commented 9 years ago

docker run -d -p "80:80" --name otrs -e OTRS_DB_SERVER=10.16.0.61 -e OTRS_DB_USER=mariadb -e OTRS_DB=mariadb -e OTRS_DB_PASSWORD=password -e OTRS_ROOT_PASSWORD=123 -e OTRS_INSTALL=yes juanluisbaptiste/otrs

docker logs: ERROR 2005 (HY000): Unknown MySQL server host '-p' (2) DB server still isn't up, sleeping a little bit ...

is my environment variable name wrong? thanks.

juanluisbaptiste commented 9 years ago

I said:

"The other option would be to modify the code to check for new environment variables like OTRS_DB_SERVER, OTRS_DB_PORT and if they are set, use those instead of the harcoded mariadb container name (Take a look at run.sh and functions.sh). PR welcome :)

You need to write that code your self, or use the first option.

miaohf commented 6 years ago

image oh,it's OTRS_DB_SERVER not OTRS_DB_HOST. I think something was wrong in README on the hub.docker.com,please check it

juanluisbaptiste commented 6 years ago

It is OTRS_DB_HOST:

[ -z "${OTRS_DB_HOST}" ] && OTRS_DB_HOST="mariadb"