美文网首页
docker-compose安装mysql

docker-compose安装mysql

作者: TechLogs | 来源:发表于2020-05-09 23:59 被阅读0次

    准备挂载文件

    准备文件

    docker-compose.yml

    # docker-compose --compatibility up -d
    
    version: "3.1"
    services:
      mysql:
        image: mysql:5.7
        container_name: mysql
        environment:
          MYSQL_ROOT_PASSWORD: "yourpassword"
          MYSQL_USER: 'test'
          MYSQL_PASS: 'yourpassword'
        restart: always
        ports:
          - 3306:3306
        volumes: #不允许使用'/'根目录,
          - /usr/local/mysql/data:/var/lib/mysql
          - /usr/local/mysql/my.cnf:/etc/mysql/my.cnf
          - /usr/local/mysql/conf.d:/etc/mysql/conf.d
          - /usr/local/mysql/mysql.conf.d:/etc/mysql/mysql.conf.d
        deploy:
          resources:
            limits:
              memory: 512M
    
    networks:
      default:
        external:
          name: net-xiaodx #使用外部网络,要提前创建 docker network create net-xiaodx --driver bridge
    

    相关文章

      网友评论

          本文标题:docker-compose安装mysql

          本文链接:https://www.haomeiwen.com/subject/uovrnhtx.html