nacos-server安装运行 (docker)

Posted wintersoft

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了nacos-server安装运行 (docker)相关的知识,希望对你有一定的参考价值。

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

以上是关于nacos-server安装运行 (docker)的主要内容,如果未能解决你的问题,请参考以下文章

docker安装Nacos

docker 安装和启动 nacos

docker 安装 nacos

在Docker中启动Nacos-Server

使用Docker部署Nacos-Server(单机版)

nacos-docker安装nacos并配置数据库