I'm using docker-compose, for db I have such container defined:
db:
build: ../builds/mysql-5.7
environment:
- MYSQL_ROOT_PASSWORD=pass
- MYSQL_DATABASE=
- MYSQL_USER=
- MYSQL_PASSWORD=
expose:
- 3306
volumes:
- /c/Users/marcin/dock-test/composers/l1.app/mysql/data/:/var/lib/mysql/
- /c/Users/marcin/dock-test/composers/l1.app/mysql/conf.d/:/etc/mysql/conf.d/
- /c/Users/marcin/dock-test/composers/l1.app/mysql/log/:/var/log/mysql/
My Dockerfile for this image is:
# Base image
FROM mysql:5.7
# Set valid file permissions - otherwise MySql won't read those files
#COPY mysql-perm-fix.sh /etc/init.d/mysql-perm-fix.sh
#RUN chmod +x /etc/init.d/mysql-perm-fix.sh
#RUN update-rc.d mysql-perm-fix.sh defaults 100
#RUN mkdir /etc/mysql/conf.d/source
#RUN cp /etc/mysql/conf.d/source/my.cnf /etc/mysql/conf.d/my.cnf
#RUN chmod -R 644 /etc/mysql/conf.d
At the moment everything is commented except base MySql image.
The problem is, when I start my containers, my MySql cnf file won't be used by MySql because of this warning:
mysqld: [Warning] World-writable config file '/etc/mysql/conf.d/my.cnf' is ignored.
I'm using Windows as my host system. The problem is that Docker mounts diretory with full permissions and they couldn't be changed.
The question - how could it be solved? As you see in my Dockerfile I've tried a few solutions, but none of them works for me (but maybe I'm doing something wrong).
At the moment I think the most reasonable solution would be mounting MySql conf files not directly into /etc/mysql/conf.d/
but into some other directory and copy those files to /etc/mysql/conf.d/
directory before MySql starts and set them not 777 permissions. I've tried it, but in Dockerfile those files are not present yet so they cannot be copied.
Is there any easy solution to fix it? Or maybe some MySql settings could be changed to don't care about conf file permissions?
I also cannot simple use COPY inside Dockerfile to copy Mysql config files (instead of using volumes) because I want to use those images by multiple sites and each of them might have different configuration.