Docker安装Mysql

使用Dockers部署Nacos集群

前置条件:

构建私有镜像

mysql.yml

version: "3.8"
services:
  mysql:
    image: mysql:5.7
    #    container_name: mysql
    # swarm 模式不支持restart
    #    restart: always
    ports:
      - "3306:3306"
    environment:
      - MYSQL_ROOT_PASSWORD=root
    networks:
      - swarm_net
    volumes:
      - mysql_logs:/var/log/mysql
      - mysql_data:/var/lib/mysql
      - mysql_config:/etc/mysql
    deploy:
      replicas: 1
      placement:
        constraints:
          #  要在对应swarm节点添加label docker node update --label-add mysql=master workId
          - node.labels.mysql == master
volumes:
  mysql_config:
  mysql_logs:
  mysql_data:
networks:
  swarm_net:
    # external: true 时 要手动创建这个网络  docker network create -d overlay swarm_net
    external: true
posted @ 2024-02-26 22:12  菜阿  阅读(8)  评论(0编辑  收藏  举报