version: '3.2'
services:
  redis5:
    image: redis:5
    container_name: redis5
    restart: always
    environment:
      - ALLOW_EMPTY_PASSWORD=yes
    command: redis-server --appendonly yes --requirepass 123456
    volumes:
      - redis:/data #数据文件挂载
    ports:
      - 6379:6379
  nacos-registry:
    image: nacos/nacos-server:v2.2.3
    container_name: nacos
    environment:
      - PREFER_HOST_MODE=hostname
      - MODE=standalone
      - SPRING_DATASOURCE_PLATFORM=mysql
      - MYSQL_SERVICE_HOST=mysql
      - MYSQL_SERVICE_DB_NAME=nacos
      - MYSQL_SERVICE_PORT=3306
      - MYSQL_SERVICE_USER=root
      - MYSQL_SERVICE_PASSWORD=123456
      - MYSQL_SERVICE_DB_PARAM=characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false&allowPublicKeyRetrieval=true
    #  volumes:
    #    - /docker/service/env/nacos:/home/nacos/init.d
    ports:
      - "8848:8848"
      - "9555:9555"
      - "9848:9848"
      - "9849:9849"
    restart: on-failure
    external_links:
      - mysql:db #可以用db这个域名访问mysql服务
    depends_on:
      - mysql

  mysql:
    image: mysql
    container_name: mysql
    command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci --lower_case_table_names=1  --log_bin_trust_function_creators=1  --max_allowed_packet=100G --tmp_table_size=256M --key_buffer_size=512M --innodb_log_file_size=1024M
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: 123456 #设置root帐号密码
    ports:
      - 3306:3306
    volumes:
      - mysql8:/var/lib/mysql #数据文件挂载

volumes:
  redis:
    external: true
  mysql8:
    external: true
如果觉得我的文章对你有用,请随意赞赏