我写了docker-compose.yml:
version: '2.2' services:
mysql57:
image: mysql/mysql-server:5.7
environment:
MYSQL_ROOT_PASSWORD: root
volumes:
- /home/Docker/mysql5.7/mysql:/var/lib/mysql
ports:
- "127.0.0.11:3306:3306/tcp"
labels:
io.rancher.scheduler.affinity:host_label: server-fvs21=true
io.rancher.container.pull_image: always
mysql55:
image: mysql/mysql-server:5.5
environment:
MYSQL_ROOT_PASSWORD: root
volumes:
- /home/Docker/mysql5.5/mysql:/var/lib/mysql
ports:
- "127.0.0.1:3306:3306/tcp"
labels:
io.rancher.scheduler.affinity:host_label: server-fvs21=true
io.rancher.container.pull_image: alwa1ys
networks:
default:
包括2个mysql(5.5,5.7)。 现在我有一个问题,其解决方案需要更改mysql配置。 Mysql配置位于/home/Docker/config/my5.5.cnf和/home/Docker/config/my5.7.cnf 但我改变这些文件并没有任何反应。我怎样才能在docker-compose.yml中指出它们的对抗方式。提前致谢
答案 0 :(得分:1)
您需要在volumes
部分中安装配置文件,如下所示:
volumes:
- /home/Docker/mysql5.5/mysql:/var/lib/mysql
- /home/Docker/config/my5.5.cnf:/etc/mysql/my.cnf # something like this
此处/etc/mysql/my.cnf
是版本5.5
中的默认cnf位置。根据{{3}}版本5.7
中的默认cnf为/etc/mysql/mysql.conf.d/mysqld.cnf
(如果不是,你可能需要查看官方文件)