Skip to content

Commit 1d50dbf

Browse files
committed
Rewrite the custom config file section
1 parent 715a696 commit 1d50dbf

File tree

2 files changed

+10
-18
lines changed

2 files changed

+10
-18
lines changed

mysql/README.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,17 @@ The MySQL Server log is available through Docker's container log:
5252

5353
## Using a custom MySQL configuration file
5454

55-
The MySQL startup configuration is specified in the file `/etc/mysql/my.cnf`. If you want to customize this configuration for your own purposes, you can create your alternative configuration file in a directory on the host machine and then mount this file in the appropriate location inside the `mysql` container, effectively replacing the standard configuration file.
55+
The MySQL 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. Settings in files in this directory will augment and/or override settings in `/etc/mysql/my.cnf`. If you want to use a customized MySQL 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 `mysql` container.
5656

57-
If you want to base your changes on the standard configuration file, start your `%%REPO` container in the standard way described above, then do:
57+
If `/my/custom/config-file` is the path and name of your custom configuration file, you can start your `mysql` container like this (note that only the directory path of the custom config file is used in this command):
5858

59-
docker exec -it some-mysql cat /etc/mysql/my.cnf > /my/custom/config-file
59+
docker run --name some-mysql -v /my/custom:/etc/mysql/conf.d -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag
6060

61-
... where `/my/custom/config-file` is the path and name of the new configuration file. Then start a new `mysql` container like this:
62-
63-
docker run --name new-conf-mysql -v /my/custom/config-file:/etc/mysql/my.cnf -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag
64-
65-
This will start a new container `new-conf-mysql` where the MySQL instance uses the startup options specified in `/my/custom/config-file`.
61+
This will start a new container `some-mysql` where the MySQL instance uses the combined startup settings from `/etc/mysql/my.cnf` and `/etc/mysql/conf.d/config-file`, with settings from the latter taking precedence.
6662

6763
Note that users on host systems with SELinux enabled may see issues with this. The current workaround is to assign the relevant SELinux policy type to your new config file so that the container will be allowed to mount it:
6864

69-
chcon -Rt svirt_sandbox_file_t /my/custom/config-file
65+
chcon -Rt svirt_sandbox_file_t /my/custom
7066

7167
## Environment Variables
7268

mysql/content.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,17 @@ The MySQL Server log is available through Docker's container log:
4444

4545
## Using a custom MySQL configuration file
4646

47-
The MySQL startup configuration is specified in the file `/etc/mysql/my.cnf`. If you want to customize this configuration for your own purposes, you can create your alternative configuration file in a directory on the host machine and then mount this file in the appropriate location inside the `%%REPO%%` container, effectively replacing the standard configuration file.
47+
The MySQL 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. Settings in files in this directory will augment and/or override settings in `/etc/mysql/my.cnf`. If you want to use a customized MySQL 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 `%%REPO%%` container.
4848

49-
If you want to base your changes on the standard configuration file, start your `%%REPO` container in the standard way described above, then do:
49+
If `/my/custom/config-file` is the path and name of your custom configuration file, you can start your `%%REPO%%` container like this (note that only the directory path of the custom config file is used in this command):
5050

51-
docker exec -it some-%%REPO%% cat /etc/mysql/my.cnf > /my/custom/config-file
51+
docker run --name some-%%REPO%% -v /my/custom:/etc/mysql/conf.d -e MYSQL_ROOT_PASSWORD=my-secret-pw -d %%REPO%%:tag
5252

53-
... where `/my/custom/config-file` is the path and name of the new configuration file. Then start a new `%%REPO%%` container like this:
54-
55-
docker run --name new-conf-%%REPO%% -v /my/custom/config-file:/etc/mysql/my.cnf -e MYSQL_ROOT_PASSWORD=my-secret-pw -d %%REPO%%:tag
56-
57-
This will start a new container `new-conf-%%REPO%%` where the MySQL instance uses the startup options specified in `/my/custom/config-file`.
53+
This will start a new container `some-%%REPO%%` where the MySQL instance uses the combined startup settings from `/etc/mysql/my.cnf` and `/etc/mysql/conf.d/config-file`, with settings from the latter taking precedence.
5854

5955
Note that users on host systems with SELinux enabled may see issues with this. The current workaround is to assign the relevant SELinux policy type to your new config file so that the container will be allowed to mount it:
6056

61-
chcon -Rt svirt_sandbox_file_t /my/custom/config-file
57+
chcon -Rt svirt_sandbox_file_t /my/custom
6258

6359
## Environment Variables
6460

0 commit comments

Comments
 (0)