0

I wrote 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:

That include 2 mysql(5.5,5.7). And now I have a problem whose solution requires changing mysql configs. Mysql config is situated in /home/Docker/config/my5.5.cnf and /home/Docker/config/my5.7.cnf But I change these files and nothing happens. How can I indicate the confrontational way to them in the docker-compose.yml. Thanks in advance

  • Did you exec inside container and set config inside it ? – Truong Dang May 22 '18 at 10:46
  • @TruongDang I set value in container :`SET GLOBAL max_allowed_packet=16777216;` after that reload docker. (ctrl+p+q, `docker container restart id_container`). After sign in container, in mysql and show my value. My value my is that was before. And I want set it in my5.5.cnf – Павел Кушнеревич May 22 '18 at 10:56

1 Answers1

2

You need to mount the config files in volumes section like this:

volumes:
- /home/Docker/mysql5.5/mysql:/var/lib/mysql
- /home/Docker/config/my5.5.cnf:/etc/mysql/my.cnf # something like this

Here /etc/mysql/my.cnf is default cnf location in version 5.5. And according to this thread default cnf in version 5.7 is /etc/mysql/mysql.conf.d/mysqld.cnf (If not you may need to look in the official doc)

leninhasda
  • 1,620
  • 11
  • 18