https://nacos.io/en-us/docs/quick-start-docker.html
https://github.com/nacos-group/nacos-docker
mkdir /opt/nacos-server/init.d -p
vim /opt/nacos-server/Dockerfile
FROM nacos/nacos-server:1.1.0 EXPOSE 8848 9555
vim /opt/nacos-server/init.d/custom.properties
#spring.security.enabled=false #management.security=false #security.basic.enabled=false #nacos.security.ignore.urls=/** #management.metrics.export.elastic.host=http://localhost:9200 # metrics for prometheus management.endpoints.web.exposure.include=* # metrics for elastic search #management.metrics.export.elastic.enabled=false #management.metrics.export.elastic.host=http://localhost:9200 # metrics for influx #management.metrics.export.influx.enabled=false #management.metrics.export.influx.db=springboot #management.metrics.export.influx.uri=http://localhost:8086 #management.metrics.export.influx.auto-create-db=true #management.metrics.export.influx.consistency=one #management.metrics.export.influx.compressed=true
vim /opt/nacos-server/docker-compose.yml
version: "2" services: nacos: image: nacos-server-standalone container_name: nacos-server-standalone build: context: . dockerfile: Dockerfile environment: - PREFER_HOST_MODE=hostname - MODE=standalone - SPRING_DATASOURCE_PLATFORM=mysql - MYSQL_MASTER_SERVICE_HOST=192.168.1.5 - MYSQL_MASTER_SERVICE_PORT=3306 - MYSQL_MASTER_SERVICE_DB_NAME=nacos - MYSQL_MASTER_SERVICE_USER=root - MYSQL_MASTER_SERVICE_PASSWORD=123456 - MYSQL_SLAVE_SERVICE_HOST=192.168.1.5 - MYSQL_SLAVE_SERVICE_PORT=3306 volumes: - ./logs/:/home/nacos/logs - ./init.d/custom.properties:/home/nacos/init.d/custom.properties ports: - "8848:8848" - "9555:9555" restart: on-failure
cd /opt/nacos-server
docker-compose build
docker-compose up -d --force-recreate
docker-compose down
docker-compose restart
查看日志
docker logs --tail="500" nacos-server-standalone
查看进程
netstat -anltp|grep 8848
进入容器
docker exec -it nacos-server-standalone /bin/bash
集群配置参照:
https://nacos.io/en-us/docs/quick-start-docker.html
https://github.com/nacos-group/nacos-docker