1

I am trying to deploy the following image osticket/osticket - Docker Image | Docker Hub

In the quick start guide, they have this command line docker run commands for both mysql and the application osticket.

Quick Start

Ensure you have a MySQL container running that osTicket can use to store its data.

docker run --name osticket_mysql -d -e MYSQL_ROOT_PASSWORD=secret \  -e MYSQL_USER=osticket -e MYSQL_PASSWORD=secret -e
MYSQL_DATABASE=osticket mariadb

Now run this image and link the MySQL container.

docker run --name osticket -d --link osticket_mysql:mysql -p 8080:80 osticket/osticket

When I execute these two commands exactly as shown above, the website works via http://localhost:8080/scp/.

Now, I tried to put the same into a docker-compose.yaml file:

version: ‘3.8’
services:
osticket:
container_name: osticket-web
image: osticket/osticket
environment:
MYSQL_HOST: localhost
MYSQL_PASSWORD: secret
depends_on:
- db
ports:
- 8080:80
db:
container_name: osticket-db
image: mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: secret
MYSQL_DATABASE: osticket
MYSQL_USER: osticket
MYSQL_PASSWORD: secret

when I look at the status, the osticket-web exits

NAME COMMAND SERVICE STATUS PORTS
osticket-db “docker-entrypoint.s…” db running 3306/tcp, 33060/tcp
osticket-web “entrypoint” osticket exited (1)

Looking at the logs it says:

Install/Update osTicket
Configuring mail settings
OSTicket cron job is set to run every 5 minutes
Using external MySQL connection
Waiting for database TCP connection to become available…
Waited for 15 seconds…
Waited for 30 seconds…
Waited for 45 seconds…
Waited for 60 seconds…
Waited for 75 seconds…
Waited for 90 seconds…
Waited for 105 seconds…
Waited for 120 seconds…
Waited for 135 seconds…
Waited for 150 seconds…
Waited for 165 seconds…
Waited for 180 seconds…
************** INSTALLER FATAL ERROR ***************Timed out waiting for database TCP connection
****************************************************Die :(%

Why does the docker-compose version not work, but executing the 2 docker run commands works?

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
JKC
  • 23
  • 3
  • MYSQL_HOST: localhost changed to MYSQL_HOST: db and now when I run docker compose, I still get the following error: Using external MySQL connection Waiting for database TCP connection to become available... Connecting to database mysql://osticket@db/osticket ************** INSTALLER FATAL ERROR ***************Unable to connect to MySQL server: The server requested authentication method unknown to the client ****************************************************Die :(% – JKC Sep 21 '22 at 20:33
  • I went ahead and deployed the 2 containers manually and had a look at the docker logs of the osticket container and see the following: Install/Update osTicket Configuring mail settings OSTicket cron job is set to run every 5 minutes Using linked MySQL container Waiting for database TCP connection to become available… Connecting to database mysql://osticket@mysql/osticket Loading installation secret Updating configuration file Installing database. Please wait… Database installation successful Setting system language to en-us Install Script finished! – JKC Sep 21 '22 at 21:32
  • Apart from my answer: you should use a volume for your databases data, otherwise your data is stored within the container, that is it'll be deleted whenever the container is deleted. – Mihe Sep 21 '22 at 22:14

1 Answers1

0

There are two problems. The first one is that MYSQL_HOST has to be changed to the name of the service, that is db. The second is, that osTicket runs on PHP 7 and recommends MySQL 5.5. The default authentication method was changed in MySQL 8 and this is unknown to older clients.

Apparently, there are a few options.

  1. Use an older version of MySQL.
  2. Use a config file that sets default_authentication_plugin=mysql_native_password in the [mysqld] section as described in the link above.
  3. I was able to start osTicket using docker-compose by altering the osticket user.

For 3: first start the database using docker-compose up -d db, then execute docker exec osticket-db mysql -e "ALTER USER 'osticket'@'%' IDENTIFIED WITH mysql_native_password BY 'secret'" -uroot -psecret to change the authentication method for user 'osticket'@'%' back to the old mysql_native_password mechanism. Finally call docker-compose up -d to start the remaining service(s).

Mihe
  • 2,270
  • 2
  • 4
  • 14
  • 1
    Thank you Mihe, I changed the db from mysql to mariadb and the docker-compose worked. – JKC Sep 22 '22 at 18:37