docker-library / mysql

Docker Official Image packaging for MySQL Community Server
https://dev.mysql.com/
GNU General Public License v2.0
2.48k stars 2.21k forks source link

replication support added #1093

Open alysrylcn01 opened 1 month ago

alysrylcn01 commented 1 month ago

Tested on 8.0 folder

Example Master Usage

version: '3.8'

services:
  mysql:
    image: my-mysql-main-branch-test:latest
    container_name: master-mysql-test
    environment:
      MYSQL_ROOT_PASSWORD: password1
      MASTER_SLAVE_ROLE: MASTER
      MYSQL_REPLICATION_USER: REP_USER
      MYSQL_REPLICATION_PASSWORD: reppassword
    ports:
      - "3306:3306"
    restart: unless-stopped
    networks:
      - mysql_net

networks:
  mysql_net:
    external: true

And Slave;

version: '3.8'

services:
  mysql:
    image: my-mysql-main-branch-test:latest
    container_name: slave1-mysql-test
    environment:
      MYSQL_ROOT_PASSWORD: password1
      MASTER_SLAVE_ROLE: SLAVE
      MYSQL_MASTER_SERVICE_HOST: master-mysql-test
      MYSQL_REPLICATION_USER: REP_USER
      MYSQL_REPLICATION_PASSWORD: reppassword
    ports:
      - "3307:3306"
    restart: unless-stopped
    networks:
      - mysql_net

networks:
  mysql_net:
    external: true
tianon commented 1 month ago

I'm glad you were able to make this work for your use case! Unfortunately, this is not code we want to maintain.

The good news is that the entrypoint script is explicitly designed such that you can source it in a new script and re-use the functions to implement your own logic like this without too much overhead/maintenance burden (essentially just maintaining your new functionality; see #471 and https://github.com/docker-library/postgres/pull/496 for details).