Configuring Mysql Server Settings on Secondary Convenience Images

I have setup a workflow that uses circleci next-gen convenience images, primary is openjdk and secondary is mysql. Everything works perfectly and I can talk to the secondary image via 127.0.0.1 to do what I need via mysql client.

The only problem is I cant work out/find a way to configure mysql server settings (that I would normally my adding/changing my.cnf) such as setting lower_case_table_names or explicit_defaults_for_timestamp that we need set. I know there are limitations to how docker images can communicate so understand if this may not be possible.

Definately aware that we can do our own docker images to configure things exactly how we want but we like the simplicity of using the convenience images. Mainly I am just trying to figure out if I am missing something obvious about how to configure the secondary images or if others use the convenience images with all default settings.

While I’m not certain about your exact configuration options, even with secondary images you should be able to pass in configuration options as command line arguments to the MySql command that’s executed when the docker container runs.

Here’s a docs page on them, which might be of help: Choosing an Executor Type - CircleCI

1 Like

Thanks for your reply @zmarkan. That was what I was after, I think I missed being able to run commands on the secondary image like that when I was reading the documentation, I have the below working now.

  docker_circleci_mysql:
    docker:
      - image: cimg/openjdk:8.0.242
        environment:
          CI_WORKING_DIR: /home/circleci/project
          MYSQL_USER: root
          MYSQL_PASSWORD:
      - image: circleci/mysql:5.7.21
        environment:
          MYSQL_USER: root
          MYSQL_ALLOW_EMPTY_PASSWORD: true
        command: [--lower_case_table_names=1]

Only thing I cant work out is how to set multiple mysql server variables at the same time, so for example I have tried:

command: [--lower_case_table_names=1]
command: [--explicit_defaults_for_timestamp=0]

and have tried

command: [--lower_case_table_names=1 --explicit_defaults_for_timestamp=0]

Multiple commands work using a comma I realised, complete config example below in case others come across this and need it. Thanks again for pointing me in the right direction @zmarkan!

  docker_circleci_mysql:
    docker:
      - image: cimg/openjdk:8.0.242
        environment:
          CI_WORKING_DIR: /home/circleci/project
          MYSQL_USER: root
          MYSQL_PASSWORD:
      - image: circleci/mysql:5.7.21
        environment:
          MYSQL_USER: root
          MYSQL_ALLOW_EMPTY_PASSWORD: true
        command: [--lower_case_table_names=1, --explicit_defaults_for_timestamp=0]
1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.