version: '3' services: mysql_master: image: mysql:5.7 hostname: "mysql_master" container_name: mysql_master restart: always environment: MYSQL_ROOT_PASSWORD: root MYSQL_PORT: 3306 MYSQL_LOWER_CASE_TABLE_NAMES: 0 volumes: - ./mysql/mysql_master.conf:/etc/mysql/conf.d/mysql.conf.cnf - /opt/mysql_master:/var/lib/mysql mysql_slave1: image: mysql:5.7 hostname: "mysql_slave1" container_name: mysql_slave1 restart: always environment: MYSQL_ROOT_PASSWORD: root MYSQL_PORT: 3306 MYSQL_LOWER_CASE_TABLE_NAMES: 0 depends_on: - mysql_master volumes: - ./mysql/mysql_slave1.conf:/etc/mysql/conf.d/mysql.conf.cnf - /opt/mysql_slave1:/var/lib/mysql mysql_slave2: image: mysql:5.7 hostname: "mysql_slave2" container_name: mysql_slave2 restart: always environment: MYSQL_ROOT_PASSWORD: root MYSQL_PORT: 3306 MYSQL_LOWER_CASE_TABLE_NAMES: 0 depends_on: - mysql_master volumes: - ./mysql/mysql_slave2.conf:/etc/mysql/conf.d/mysql.conf.cnf - /opt/mysql_slave2:/var/lib/mysql