Search code examples
dockerperconamy.cnf

How to add external my.cnf file to Percona server in Docker?


I have created docker container with Percona executing this command:

docker run -v <path-to-files-on-host-machine>:/etc/mysql/conf.d 
--name percona -p 6604:3306 -e MYSQL_ROOT_PASSWORD=12345 -d percona/percona-server:latest \
    --innodb_data_file_path=ibdata1:10M:autoextend:max:1G --sql_mode='' --character-set-server=utf8 --collation-server=utf8_general_ci;

According to documentation on DockerHub I have mount directory with my.cnf in my host machine as /etc/mysql/conf.d in Docker container.

But when I start my container Percona doesn't read settings from my custom my.cnf. Also I tried to create my.cnf with errors to crash Percona on start. But no effect.

How can I attach custom my.cnf to Percona Docker container?


Solution

  • I have solved my problem in this way:

    • start container with attached STDIN: docker start -i percona
    • it was error in output: Warning: World-writable config file '/etc/mysql/conf.d/my.cnf' is ignored

    So my.cnf had wrong permissions. I solved it that way: chmod 755 /etc/mysql/conf.d/my.cnf