1

I am trying to build a docker-compose file for the development of a dotcms site.

I have the following in my docker-compose.yml:

version: "3"
  services:
  dotcms:
    image: openjdk
    command: /app/bin/startup.sh run
    ports:
      - 8080:8080
    volumes:
      - ./:/app
    depends_on:
      - db
  db:
    image: mysql
    command: mysqld --character-set-server=utf8 --collation-server=utf8_unicode_ci --init-connect='SET NAMES UTF8;' --innodb-flush-log-at-trx-commit=0 --lower_case_table_names=1
    volumes:
      - ./db:/var/lib/mysql
    ports:
      - 3308:3306
    environment:
      MYSQL_ROOT_PASSWORD: dotcms
      MYSQL_DATABASE: dotcms
      MYSQL_USER: dotcms
      MYSQL_PASSWORD: dotcms

after running docker-compose up

When I try to load localhost:8080 I get a 500 error. I look in the dotcms database and there is a table called db_version however that is all there is. No other tables are created.

I have tried deleting the dotcms database and recreating then running docker-compose up once again, but I get the same issue.

I have also tried deleting the ./db folder (the mounted volume for the mysql database) and rerunning, again same issue.

Update

I have updated the dotcms container to run: command: sh -c "sleep 30 && /app/bin/startup.sh run"

I also added --general_log=1 --general_log_file=/var/log/mysql/query.log to the db command

I deleted the local db folder and ran docker-composer up again.

Still getting the same results. Here are the logs:

dotcms.log: https://pastebin.com/5WnrarK8
catalina.log: https://pastebin.com/Z3vHbnp2
localhost.log: https://pastebin.com/S2CSPqxQ

from the db container

mysql.error.log: https://pastebin.com/4bYwB2Z2
mysql.query.log: https://pastebin.com/maDUXFm5
(This query file was very large, I removed everything before the first entry showing: mysql-connector-java-5.1.37

docker logs <container id>
db.container.log: https://pastebin.com/Wz7aRhVc
dotcms.container.log: https://pastebin.com/qNVBfTpf

Community
  • 1
  • 1
Shawn Northrop
  • 5,826
  • 6
  • 42
  • 80
  • and how is this related to java ? – Scary Wombat Sep 21 '17 at 01:57
  • dotcms is a java application – Shawn Northrop Sep 21 '17 at 02:01
  • Is this a typo ? `ports: - 3308:3306` ? – Scary Wombat Sep 21 '17 at 02:02
  • No this forwards 127.0.0.1:3308 to db:3306 I have a local mysql server running on 127.0.0.1:3306 – Shawn Northrop Sep 21 '17 at 02:03
  • Oh I see. does dotcms have any logging as a 500 error would seem to indicate that the server side code is throwing an exception – Scary Wombat Sep 21 '17 at 02:05
  • Yes... lots of logging but I'm not sure what to make of most of it... I believe the 500 error is being returned from this error: `Table 'dotcms.cluster_server' doesn't exist` however this table should be created on first execution of `./startup.sh` – Shawn Northrop Sep 21 '17 at 02:11
  • 1
    Put complete logs on pastebin.com link and add it to your question. Without logs it is tough to say. Also how is the data getting populated? Try changing `command: /app/bin/startup.sh run` to `command: sh -c "sleep 30 && /app/bin/startup.sh run"` its not a race condition to find DB up early – Tarun Lalwani Sep 21 '17 at 05:44
  • Reproduce the error one more time and collect the logs from both of the containers. Use command `docker logs ` – Sasha Shpota Sep 21 '17 at 07:13
  • @TarunLalwani the data is supposed to get populated on the first run of `startup.sh`. If I take the same codebase, update the database config to use `localhost` vs `db` and then run `startup.sh` the database is populated and the site works. This script assumes that there is an empty database already created. – Shawn Northrop Sep 21 '17 at 17:46

2 Answers2

1

I'm not a mysql expert, but the log suggests this is a mysql issue unrelated to dotCMS. The mysql.error.log shows that mysql shuts down almost immediately after it starts up - meaning it may be shutting down before dotCMS has a chance to access the database, causing the dotCMS query to fail.

Consider this section of the mysql.error.log (lines 38-44 in your pastebin):

2017-09-19T08:13:37.664410Z 0 [Note] mysqld: ready for connections.
Version: '5.7.19'  socket: '/tmp/tmp.Dlc2I8QgCt/mysqld.sock'  port: 3306  MySQL Community Server (GPL)
2017-09-19T08:13:37.664422Z 0 [Note] Executing 'SELECT * FROM INFORMATION_SCHEMA.TABLES;' to get a list of tables using the deprecated partition engine. You may use the startup option '--disable-partition-engine-check' to skip this check.
2017-09-19T08:13:37.664430Z 0 [Note] Beginning of list of non-natively partitioned tables
2017-09-19T08:13:37.664491Z 0 [Note] Giving 1 client threads a chance to die gracefully
2017-09-19T08:13:37.664553Z 0 [Note] Shutting down slave threads
2017-09-19T08:13:37.664684Z 3 [ERROR] 1053  Server shutdown in progress

There's almost no time between the [Note] mysqld: ready for connections message and the [ERROR] 1053 Server shutdown in progress message. And the mysql query shown in the dotcms.log error message doesn't show at all in the mysql.query.log (or at least in the portion of it you've posted), indicating that it never reached the mysql database.

So if you haven't already, I suggest you try starting up mysql in the Docker container without starting dotCMS at all, and check the logs to make sure it starts up and stays up without problems. Then add the dotCMS startup, and if that causes mysql to have issues, compare the mysql logs with and without dotCMS to see what changes.

Other than that, double-check your dotCMS context.xml file (in /dotserver/tomcat-8.0.18/webapps/ROOT/META-INF) to make sure you've configured properly to access the mysql db.

0

I was facing a different error but you made my day with the parameter

command: mysqld --character-set-server=utf8 --collation-server=utf8_unicode_ci --init-connect='SET NAMES UTF8;' --innodb-flush-log-at-trx-commit=0 --lower_case_table_names=1

I was trying dockerized mysql (5.6, 5.7, 5.7.29, etc...) but SQL initialization was always failing due to SQL errors possible related with collation or tablenames case.

Thank you very much

manuelbcd
  • 3,106
  • 1
  • 26
  • 39