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

OTRS_DB_HOST has no affect #43

Closed markuman closed 5 years ago

markuman commented 5 years ago

I've started your container with

docker run -ti \
--name otrs \
--network db \
-p 8080:80 \
-e OTRS_INSTALL=yes \
-e OTRS_DB_HOST=mariadb \
-e OTRS_DB_NAME=otrs \
-e OTRS_DB_PORT=3306 \
-e OTRS_DB_USER=otrs \
-e OTRS_DB_PASSWORD=otrs \
-e OTRS_LANGUAGE=de \
-e MYSQL_ROOT_PASSWORD=password \
juanluisbaptiste/otrs:6.0.11

the mariadb server is available and reachable in the db network. e.g. I can ping the mariadb server from the running otrs container

docker exec -ti otrs ping -c 2 mariadb
PING mariadb (10.0.1.5) 56(84) bytes of data.
64 bytes from 10.0.1.5 (10.0.1.5): icmp_seq=1 ttl=64 time=0.047 ms
64 bytes from 10.0.1.5 (10.0.1.5): icmp_seq=2 ttl=64 time=0.060 ms

--- mariadb ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1002ms
rtt min/avg/max/mdev = 0.047/0.053/0.060/0.009 ms

but connecting otrs failed, because he try to connect to localhost instead of using mariadb


 Message: Can't connect to MySQL server on '127.0.0.1' (111)
juanluisbaptiste commented 5 years ago

Hi,

Please post the error logs, the OTRS_DB_HOST var is working correctly, starting because its default value is mariadb:

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

And the it uses it to connect to the database server:

mysqlcmd="mysql -uroot -h ${OTRS_DB_HOST} -P ${OTRS_DB_PORT} -p${MYSQL_ROOT_PASSWORD} "
juanluisbaptiste commented 5 years ago

Also the recommended way of running this container is using docker-compose with the provided docker-compose.yml file. It makes things much easier.

juanluisbaptiste commented 5 years ago

Also the recommended way of running this container is using docker-compose with the provided docker-compose.yml file. It makes things much easier.

Thinking about it, I think this is the problem. There are a bunch of host volumes that you need to mount to save container configuration outside it, to tell you the truth I haven't tested this image in a long time without mounted volumes as it doesn't make sense in a production environment.

markuman commented 5 years ago

Also the recommended way of running this container is using docker-compose with the provided docker-compose.yml file. It makes things much easier.

Yes, I understand, but I wanted to try to include this container in my existing container ecosystem, like - reuse the existing mariadb container.

Thinking about it, I think this is the problem. There are a bunch of host volumes that you need to mount to save container configuration outside it, ...

But - with or without host volumes - the difference is that the configuration is gone when the container is gone. This should be sufficient for a one-time test. But nevermind, I will try it later too.

juanluisbaptiste commented 5 years ago

Yes, I understand, but I wanted to try to include this container in my existing container ecosystem, like - reuse the existing mariadb container.

Why not just use external_links ? https://docs.docker.com/compose/compose-file/#external_links

But - with or without host volumes - the difference is that the configuration is gone when the container is gone. This should be sufficient for a one-time test. But nevermind, I will try it later too.

That's the idea, but there is a setup code run to initialize the initial configuration on a mounted volume that I haven't tested it in a long time without the mounted volumes.

markuman commented 5 years ago

Why not just use external_links ?

Because linking is deprecated and has no advantages over docker networks. https://docs.docker.com/network/links/

juanluisbaptiste commented 5 years ago

If you are using docker networks then you could attach to your mariadb network.