Kubernetes/Docker/Docs/Docker部署Nacos.md
offends 7a2f41e7d6
All checks were successful
continuous-integration/drone Build is passing
synchronization
2024-08-07 18:54:39 +08:00

1.3 KiB

本文作者:丁辉

Docker部署Nacos

官网文档

  1. 启动 MYSQL

    docker run --name nacos-mysql --restart=always \
      -p 3306:3306 \
      -v /data/mysql:/var/lib/mysql \
      -e MYSQL_USER=nacos \
      -e MYSQL_PASSWORD=nacos \
      -e MYSQL_DATABASE=nacos \
      -e MYSQL_ROOT_PASSWORD=root \
      -d mysql:latest
    
  2. 启动 NACOS

    docker run --name nacos --restart=always \
      -p 8848:8848 \
      -e MYSQL_SERVICE_HOST=${MYSQL_HOST} \
      -e MYSQL_SERVICE_PORT=3306 \
      -e MYSQL_SERVICE_USER=nacos \
      -e MYSQL_SERVICE_PASSWORD=nacos \
      -e MYSQL_SERVICE_DB_NAME=nacos \
      -e MODE=standalone \
      -e PREFER_HOST_MODE=hostname \
      -d mysql:latest
    
  3. 开启登录

    vi /data/nacos/application.properties
    

    内容如下

    # vi /data/nacos/application.properties
    nacos.core.auth.enabled=true
    nacos.core.auth.server.identity.key=nacos
    nacos.core.auth.server.identity.value=nacos
    
    nacos.core.auth.plugin.nacos.token.secret.key=SecretKey012345678901234567890123456789012345678901234567890123456789
    
  4. 访问:http://localhost:8848/nacos/#/login

启动挂载配置文件

-e 	/data/nacos/application.properties:/home/nacos/conf/application.properties