拉镜像,版本查看:https://github.com/nacos-group/nacos-docker
docker pull nacos/nacos-server:1.1.4 //稳定版,无权限
docker pull nacos/nacos-server:1.3.1 //稳定版,有权限
创建数据目录
mkdir -p/home/dockerdata/nacos/logs
mkdir -p /home/dockerdata/nacos1.3.1/logs
运行镜像 默认账号密码:nacos/nacos
#1.1.4
docker run -d \
-e PREFER_HOST_MODE=ip \
-e MODE=standalone \
-e SPRING_DATASOURCE_PLATFORM=mysql \
-e MYSQL_MASTER_SERVICE_HOST=172.168.1.33 \
-e MYSQL_MASTER_SERVICE_PORT=3306 \
-e MYSQL_MASTER_SERVICE_USER=root \
-e MYSQL_MASTER_SERVICE_PASSWORD=root \
-e MYSQL_MASTER_SERVICE_DB_NAME=nacos \
-e MYSQL_SLAVE_SERVICE_HOST=172.168.1.33 \
-e MYSQL_SLAVE_SERVICE_PORT=3306 \
-v /home/dockerdata/nacos/logs:/home/nacos/logs \
-p 8848:8848 \
--name nacos \
--restart=always \
nacos/nacos-server:1.1.4
#1.3.1
docker run -d \
-e PREFER_HOST_MODE=ip \
-e MODE=standalone \
-e SPRING_DATASOURCE_PLATFORM=mysql \
-e MYSQL_SERVICE_HOST=172.168.1.33 \
-e MYSQL_SERVICE_PORT=3306 \
-e MYSQL_SERVICE_USER=root \
-e MYSQL_SERVICE_PASSWORD=root \
-e MYSQL_SERVICE_DB_NAME=nacos \
-e TIME_ZONE='Asia/Shanghai' \
-v /home/dockerdata/nacos1.3.1/logs:/home/nacos/logs \
-p 8848:8848 \
--name nacos1.3.1 \
--restart=always \
nacos/nacos-server:1.3.1
nacos初始化sql,需要先创建nacos数据库后,然后执行下面的sql
https://github.com/alibaba/nacos/blob/master/config/src/main/resources/META-INF/nacos-db.sql
View Code
1.1.4 升级1.3.1需要执行的脚本
ALTERTABLE`roles`ADDUNIQUE `uk_username_role` (`username`, `role`);CREATETABLEpermissions (
role varchar(50)NOTNULL,
resource varchar(512)NOTNULL,
action varchar(8)NOTNULL,
constraintuk_role_permissionUNIQUE (role,resource,action)
) ROW_FORMAT=DYNAMIC;
如果启动1.3.1报错,比如mysql时区异常,把conf配置文件弄到主机上
dockercpnacos1.3.1:/home/nacos/conf /home/dockerdata/nacos1.3.1
#修改mysql的配置后
docker stop nacos1.3.1
docker rm nacos1.3.1
docker run -d \
-e PREFER_HOST_MODE=ip \
-e MODE=standalone \
-e SPRING_DATASOURCE_PLATFORM=mysql \
-e MYSQL_SERVICE_HOST=172.168.1.33 \
-e MYSQL_SERVICE_PORT=3306 \
-e MYSQL_SERVICE_USER=root \
-e MYSQL_SERVICE_PASSWORD=root \
-e MYSQL_SERVICE_DB_NAME=nacos \
-e TIME_ZONE='Asia/Shanghai' \
-v /home/dockerdata/nacos1.3.1/logs:/home/nacos/logs \
-v /home/dockerdata/nacos1.3.1/conf:/home/nacos/conf \
-p 8848:8848 \
--name nacos1.3.1 \
--restart=always \
nacos/nacos-server:1.3.1