1: mysql 创建数据库, 执行nacos脚本
CREATE database if NOT EXISTS `nacos` default character set utf8mb4 collate utf8mb4_unicode_ci; use `nacos`;执行 nacos-mysql.sql 脚本
2: docker-compose 配置
1: 环境变量
EFER_HOST_MODE=hostname
MODE=standalone # 单机启动
SPRING_DATASOURCE_PLATFORM=mysql
MYSQL_SERVICE_HOST= mysql ip
MYSQL_SERVICE_DB_NAME=nacos
MYSQL_SERVICE_PORT= mysql 端口
MYSQL_SERVICE_USER=mysql 用户名
MYSQL_SERVICE_PASSWORD=mysql 密码
MYSQL_SERVICE_DB_PARAM=characterEncoding=utf8&connectTimeout=3000&socketTimeout=3000&autoReconnect=true&useSSL=false
2: docker-compose 配置, 防火墙记得开放端口
nacos:
container_name: nacos
environment:
EFER_HOST_MODE: hostname
MODE: standalone
MYSQL_SERVICE_DB_NAME: nacos
MYSQL_SERVICE_DB_PARAM: characterEncoding=utf8&connectTimeout=3000&socketTimeout=3000&autoReconnect=true&useSSL=false
MYSQL_SERVICE_HOST: mysql ip
MYSQL_SERVICE_PASSWORD: mysql 密码
MYSQL_SERVICE_PORT: mysql 端口
MYSQL_SERVICE_USER: mysql 用户名
SPRING_DATASOURCE_PLATFORM: mysql
image: nacos/nacos-server:v2.1.0-BETA #使用nacos镜像, mysql8用此镜像否则添加失败
ports:
- 8848:8848
restart: on-failure
volumes:
- /usr/soft/nacos:/home/nacos/logs:rw
- /usr/soft/docker/init.d/custom.properties:/home/nacos/init.d/custom.properties
3: docker-compose 启动及及访问:
日志查看:
4:界面访问: