How to connect Docker CAS to Docker MySQL database?

121 views
Skip to first unread message

Suoke Sou

unread,
Apr 10, 2025, 10:37:33 PM4/10/25
to CAS Community

Hi,
I have some problems with running CAS using the Docker image apereo/cas:7.2.0-SNAPSHOT,Can anyone help me?

When CAS running without application.properties,I can use casuser and Mellon as the username and password to test the default authentication scheme in CAS.

But when I use the application.properties to make CAS working with the Docker image mysql:8.0.21, CAS can not connecting to the mysql database.

This problem has been bothering me for two weeks. I hope someone can help me.

Here is my docker command:

docker run --name CAS --network=cas -e TZ=Asia/Shanghai -e SERVER_SSL_ENABLED=false -e SERVER_PORT=8080 -v /docker/cas:/etc/cas -p 8181:8080 apereo/cas:7.2.0-SNAPSHOT
Copy
docker run --name mysql --network=cas -e TZ=Asia/Shanghai -v /docker/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=111111 -p 3308:3306 -d mysql:8.0.21
Copy
docker run --name phpmyadmin --network=cas -e PMA_HOSTS=172.18.0.2 -p 81:80 phpmyadmin:latest
Copy

Here is my application.properties in /docker/cas/config:

cas.server.name=http://1.1.1.1:8181 cas.server.prefix=${cas.server.name}/cas logging.level.org.apereo=DEBUG logging.level.org.apereo.cas=DEBUG cas.authn.accept.users= cas.authn.jdbc.query[0].field-password=password cas.authn.jdbc.query[0].field-expired=expired cas.authn.jdbc.query[0].field-disabled=disabled cas.authn.jdbc.query[0].driver-class=com.mysql.cj.jdbc.Driver cas.authn.jdbc.query[0].password-encoder.type=NONE cas.authn.jdbc.query[0].user=root cas.authn.jdbc.query[0].password=111111 cas.authn.jdbc.query[0].sql=select * from user where name=? cas.authn.jdbc.query[0].url=jdbc:mysql://172.18.0.2:3306/cas?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf8&useSSL=false cas.authn.jdbc.query[0].dialect=org.hibernate.dialect.MySQLDialect
Copy

And I also put the database driver mysql-connector-java-8.0.21.jar (https://cdn.mysql.com/archives/mysql-connector-java-8.0/mysql-connector-java-8.0.21.zip) in /docker/cas/lib.

The phpmyadmin can connecting to mysql database, But I can not see any sessions from CAS to mysql in phpmyadmin.

Can anyone help me?

Reply all
Reply to author
Forward
0 new messages