Steps required to run the official mysql:8.0.30-debian image on Windows 10 with custom config file E:\mysql-config\mysql-docker.cnf.
I want to use my custom config file E:\mysql-config\mysql-docker.cnf, when running the Docker Official Image mysql:8.0.30-debian, on my Windows 10 Pro machine. I'm describing the steps to get this working.
❶ mysql-docker.cnf is the only file in *E:\mysql-config*. Its content:
[mysqld]
default_authentication_plugin=mysql_native_password
log_bin_trust_function_creators=1
❷ For this mysql:8.0.30-debian image, the custom config file is /etc/mysql/conf.d/mysql.cnf.
Its permissions are: owner has read and write; groups and others has only read. Our own custom config file must have the same permissions.
❸ Mount E:\mysql-config\mysql-docker.cnf to change its permissions, we only need the directory. E:\mysql-config** gets translated to **//e/mysql-config. The mounting option is thus:
--mount type=bind,source=//e/mysql-config,target=/etc/mysql/conf.d
The command to run:
E:\>docker run -d -it --rm --name mysql-docker --mount type=bind,source=//e/mysql-config,target=/etc/mysql/conf.d -p 3306:3306 -e MYSQL_ROOT_PASSWORD=pcb.2176310315865259 mysql:8.0.30-debian
Run the container in the interactive mode with the bash process to change config file permissions:
E:\>docker exec -it mysql-docker bash
Verify that we're looking at the Windows 10 Pro directory, which has only this config file, also note its permissions:
root@5b671d85c90b:/# ls -l /etc/mysql/conf.d
total 4
-rwxrwxrwx 1 root root 95 Aug 8 11:41 mysql-docker.cnf
Change permissions to match the corresponding container custom config file. That is, owner has read and write; groups and others has only read:
root@5b671d85c90b:/# cd /etc/mysql/conf.d/
root@5b671d85c90b:/# chmod u+rw-x mysql-docker.cnf
root@5b671d85c90b:/# chmod g+r-wx mysql-docker.cnf
root@5b671d85c90b:/# chmod o+r-wx mysql-docker.cnf
Permissions should now be correct. To verify:
root@5b671d85c90b:/# ls -l
total 4
-rw-r--r-- 1 root root 95 Aug 8 11:41 mysql-docker.cnf
❹ Stop and re-run to verify the custom config file takes effects. This time, also run with proper data persistent volume with the option:
--mount source=mysqlvol,target=/var/lib/mysql
The commands to stop the container and to run are:
E:\>docker stop mysql-docker
E:\>docker run -d -it --rm --name mysql-docker -p 3306:3306 -e MYSQL_ROOT_PASSWORD=pcb.2176310315865259 --mount type=bind,source=//e/mysql-config,target=/etc/mysql/conf.d --mount source=mysqlvol,target=/var/lib/mysql mysql:8.0.30-debian
❺ Verify custom config takes effect. Using the MySQL command line to query values of the custom options. Run the interactive bash shell:
E:\>docker exec -it mysql-docker bash
Launch MySQL command line:
root@dfa641fecc0a:/# mysql -uroot -ppcb.2176310315865259
⓵ Verify default_authentication_plugin=mysql_native_password:
mysql> show variables like 'default_authentication_plugin';
+-------------------------------+-----------------------+
| Variable_name | Value |
+-------------------------------+-----------------------+
| default_authentication_plugin | mysql_native_password |
+-------------------------------+-----------------------+
1 row in set (0.01 sec)
⓶ Verify log_bin_trust_function_creators=1. Please note, 1 is reported as ON:
mysql> show variables like 'log_bin_trust_%';
+---------------------------------+-------+
| Variable_name | Value |
+---------------------------------+-------+
| log_bin_trust_function_creators | ON |
+---------------------------------+-------+
1 row in set (0.00 sec)
❻ Using a Windows MySQL client tool, we should also be able to connect to MySQL in the mysql-docker container. E.g.:
"C:\Program Files\MySQL\MySQL Server 5.5\bin\mysql" --protocol=TCP --host=localhost --port=3306 --user=root --password=pcb.2176310315865259
Since the value of default_authentication_plugin is mysql_native_password we should login successfully. I.e. we should not get the error:
ERROR 2059 (HY000): Authentication plugin 'caching_sha2_password' cannot be loaded: The specified module could not be found.
✿✿✿
It took me a while to work this one out... I document it so that it could possibly be of some helps for others. I am actually using mysql:8.0.30-debian as my development server. I'll do more documents on it later on. I hope you find this helpful and thank you for reading.
Top comments (0)