From 2bac2c3dd9b5aae1ea1711cf8551232acc1d7996 Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Wed, 28 Sep 2022 09:30:50 +1000 Subject: [PATCH] mariadb: custom configuration file Many people where custom mounting their configuration on /etc/mysql/my.cnf overriding many other defaults. The docs here simplify to the /etc/mysql/conf.d directory intended. A few people are doing user@hostname configurations and with the way skip-name-resolve is implemented in the server it not obvious how to disable this. Added docs to clarify this, and how to examine the final configuration. --- mariadb/content.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/mariadb/content.md b/mariadb/content.md index a83271f11..6f4d43281 100644 --- a/mariadb/content.md +++ b/mariadb/content.md @@ -71,16 +71,21 @@ $ docker logs some-%%REPO%% ## Using a custom MariaDB configuration file -The startup configuration is specified in the file `/etc/mysql/my.cnf`, and that file in turn includes any files found in the `/etc/mysql/conf.d` directory that end with `.cnf`. Settings in files in this directory will augment and/or override settings in `/etc/mysql/my.cnf`. If you want to use a customized MariaDB configuration, you can create your alternative configuration file in a directory on the host machine and then mount that directory location as `/etc/mysql/conf.d` inside the `%%IMAGE%%` container. +Custom configuration files should end in `.cnf` and be mounted at the directory `/etc/mysql/conf.d`. These files should contain the minimal changes from the MariaDB workload required for your application/environment. A MariaDB configuration file will have a `[mariadb]` group followed by `variable` = `value` settings per [Setting Server System Variables](https://mariadb.com/kb/en/server-system-variables/#setting-server-system-variables) or [option-prefix-variable](https://mariadb.com/kb/en/configuring-mariadb-with-option-files/#option-prefixes). -If `/my/custom/config-file.cnf` is the path and name of your custom configuration file, you can start your `%%IMAGE%%` container like this (note that only the directory path of the custom config file is used in this command): +The `%%IMAGE%%` image configuration contains the Ubuntu MariaDB variables with two custom changes for the container: + + [host-cache-size=0](https://mariadb.com/kb/en/server-system-variables/#host_cache_size) + [skip-name-resolve](https://mariadb.com/kb/en/server-system-variables/#skip_name_resolve) + +These disable the authentication of `user@hostname` users. To re-enable the `skip-name-resolve` use `disable-skip-name-resolve` as variable or arguement. When enabled, the `host-cache-size` should be sufficient for the number of containers connecting to the `%%IMAGE%%`. + +To view the resulting configuration of your `%%IMAGE%%` container: ```console -$ docker run --name some-%%REPO%% -v /my/custom:/etc/mysql/conf.d -e MARIADB_ROOT_PASSWORD=my-secret-pw -d %%IMAGE%%:latest +$ docker run --name some-%%REPO%% -v /my/custom:/etc/mysql/conf.d --rm %%IMAGE%%:latest my_print_defaults --mysqld ``` -This will start a new container `some-%%REPO%%` where the MariaDB instance uses the combined startup settings from `/etc/mysql/my.cnf` and `/etc/mysql/conf.d/config-file.cnf`, with settings from the latter taking precedence. - ### Configuration without a `cnf` file Many configuration options can be passed as flags to `mysqld`. This will give you the flexibility to customize the container without needing a `cnf` file. For example, if you want to run on port 3808 just run the following: