1、拉取镜像
docker pull nacos/nacos-server
2、挂载目录,用于映射到容器,目录按自己的情况创建
docker volume create nacos_test
mkdir -p /var/lib/docker/volumes/nacos_test/logs/ #新建logs目录
mkdir -p /var/lib/docker/volumes/nacos_test/init.d/
vim /var/lib/docker/volumes/nacos_test/init.d/custom.properties #修改配置文件
3、mysql新建nacos的数据库,并执行脚本 sql脚本地址如下:
https://github.com/alibaba/nacos/blob/master/config/src/main/resources/META-INF/nacos-db.sql
4、修改配置文件custom.properties
server.contextPath=/nacos
server.servlet.contextPath=/nacos
server.port=8848
spring.datasource.platform=mysql
db.num=1
db.url.0=jdbc:mysql://192.168.3.56:3307/nacos_test?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
db.user=root
db.password=root
nacos.cmdb.dumpTaskInterval=3600
nacos.cmdb.eventTaskInterval=10
nacos.cmdb.labelTaskInterval=300
nacos.cmdb.loadDataAtStart=false
management.metrics.export.elastic.enabled=false
management.metrics.export.influx.enabled=false
server.tomcat.accesslog.enabled=true
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i
nacos.security.ignore.urls=/,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/v1/auth/login,/v1/console/health/**,/v1/cs/**,/v1/ns/**,/v1/cmdb/**,/actuator/**,/v1/console/server/**
nacos.naming.distro.taskDispatchThreadCount=1
nacos.naming.distro.taskDispatchPeriod=200
nacos.naming.distro.batchSyncKeyCount=1000
nacos.naming.distro.initDataRatio=0.9
nacos.naming.distro.syncRetryDelay=5000
nacos.naming.data.warmup=true
nacos.naming.expireInstance=true
5、启动容器
docker run --network my_network \
--name nacos_test -d \
-p 8849:8848 \
--privileged=true \
--restart=always \
-e JVM_XMS=526m \
-e JVM_XMX=526m \
-e MODE=standalone \
-e PREFER_HOST_MODE=hostname \
-v /var/lib/docker/volumes/nacos_test/logs:/home/nacos/logs \
-v /var/lib/docker/volumes/init.d/custom.properties:/home/nacos/init.d/custom.properties \
nacos/nacos-server
标签:naming,nacos,server,v1,test,docker,安装,Docker From: https://www.cnblogs.com/ossbar/p/17813298.html