I encountered a database connection error when using Docker to deploy Moodle. While I can manually connect to the database through the command line, Moodle fails to connect automatically when it starts.
Operating System: DSM 7.2.1-69057 Update 4
Docker Version: 20.10.23, build 876964a
Moodle Version: 4.4.2 (Build: 20240812)
MariaDB Version: 11.5.2
I used the Docker image provided by Bitnami to deploy Moodle. After manually entering the Moodle container, I can successfully connect to the MariaDB database using the following command:
mariadb -h IP -u moodle -pmoodlepass moodle
However, when I start the container, Moodle reports that it is unable to connect to the database. The following error message appears in the container logs: [ERROR] Could not connect to the database.
I have checked the config.php file to confirm that the database host, username, password, and database name are correct. I have also ensured that the database user has sufficient permissions and that there are no issues with the network configuration.
I have checked the symbolic links within the container to ensure that the mysql command points to /opt/bitnami/mysql/bin/mariadb.
I tried delaying the start of the Moodle container to ensure the database service was ready, but the problem persists.
The environment variables are correctly set, and I verified these variables using docker inspect.
I want to know if there are any other configurations I might have overlooked or if there is a better way to debug this issue. Any suggestions or guidance would be greatly appreciated.
Is there a way to see the response from the database when Moodle tries to connect?