I am trying to setup Mura CMS using Docker on my local machine. MYSQL database seems not to be working.
I am using the docker-compose up command. I have been trying the following example:
https://github.com/blueriver/docker-muracms/tree/master/examples/blueriver-muracms-mysql
version: '3.3'
services:
muracms:
image: blueriver/muracms:latest
depends_on:
- svc_muradb
environment:
MURA_ADMIN_USERNAME: admin
MURA_ADMIN_PASSWORD: 5trongP@55w0rd
MURA_ADMINEMAIL: [email protected]
MURA_APPRELOADKEY: appreload
MURA_DATASOURCE: dsn_muracms
MURA_DATABASE: muradb
MURA_DBTYPE: mysql
MURA_DBUSERNAME: root
MURA_DBPASSWORD: 5trongP@55w0rd
MURA_DBHOST: svc_muradb
MURA_DBPORT: 3306
MURA_SITEIDINURLS: "false"
MURA_INDEXFILEINURLS: "true"
MURA_TESTBOX: "true"
MURA_USESSL: "false"
volumes:
- ./www/modules:/var/www/modules
- ./www/plugins:/var/www/plugins
- ./www/sites:/var/www/sites
- ./www/themes:/var/www/themes
ports:
- "8888:8888"
# DB
svc_muradb:
image: mysql:latest
environment:
MYSQL_DATABASE: muradb
MYSQL_ROOT_PASSWORD: 5trongP@55w0rd
volumes:
- vol_muradb:/var/lib/mysql
ports:
- "5001:3306"
# Mounts
volumes:
vol_muradb:
The following error message I see when I browse localhost:8888:
500 Error
Could not create connection to database server.
Code:0
Type:database
lucee.runtime.exp.DatabaseException: Could not create connection to database server.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:425)
at com.mysql.jdbc.Util.getInstance(Util.java:408)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:918)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:897)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:886)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:860)
This is because when
muracmsstart, thesvc_muradbstill not finish its init.The
depends_onjust assuresvc_muradbstart first, and then startmuracms. But the start processsvc_muradbis asynchronous. So before thesvc_muradbready, yourmuracmshas probability already want to connect the db.This issue documented in official guide, which suggest you to write a wrapper for
svc_muradbcommand.Like follows, I just give you an example:
docker-compose.yml:
wait-for-it.sh:
With above workaround, the web container will run
wait-for-it.sh, and first it will try to link its dependency containerdb:5432, only after it confirms can link to database withpsql client, then it will run the real commandpython app.py.For your part, you need to change related to
mysql client test, then everything is ok.