dock环境一键部署docker-compose.yml

version: "3.1"
networks:
  zk-net:
    name: zk-net
services:
  db:
    #构建mysql镜像
    image: mysql:8
    container_name: db # 容器名
    command: --default-authentication-plugin=mysql_native_password
      --character-set-server=utf8mb4
      --collation-server=utf8mb4_general_ci
      --max_connections=1000
    restart: always
    environment:
      - TZ=Asia/Shanghai
      - MYSQL_ROOT_PASSWORD=root #root管理员用户密码
    ports:
    - '3306:3306'  #host物理直接映射端口为6606
    volumes:
    #mysql数据库挂载到host物理机目录
    - "./data/mysql/db:/var/lib/mysql"
    #容器的配置目录挂载到host物理机目录
    - "./data/mysql/conf:/etc/mysql/conf.d"
  redis:
    # 构建redis镜像
    image: redis:6.0.9
    container_name: redis
    restart: always
    command: redis-server /usr/local/etc/redis/redis.conf

你可能感兴趣的:(数据库,redis,mysql)