【Nacos】docker-compose 一键启动 nacos

文章目录

  • 1 使用方法
  • 2 扩展说明

1 使用方法

  • 环境
    linux
    docker
    docker-compose

  • 下载
    一键启动包点击链接下载 >>>nacos.tar.gz

  • 启动

docker-compose up -d
  • 查看结果
[root@nacos nacos]# docker-compose ps
   Name                Command             State                 Ports
------------------------------------------------------------------------------------
mysq-nacos   docker-entrypoint.sh mysqld   Up      0.0.0.0:3306->3306/tcp, 33060/tcp
nacos        bin/docker-startup.sh         Up      0.0.0.0:80->8848/tcp
  • web 访问

默认用户/密码: ancos/nacos
【Nacos】docker-compose 一键启动 nacos_第1张图片

2 扩展说明

  • 安装包目录结构
[root@nacos data]# tree nacos/
nacos/
├── docker-compose.yml
├── mysql
│   ├── data
│   └── my.cnf
└── nacos
    ├── conf
    │   ├── 1.4.0-ipv6_support-update.sql
    │   ├── application.properties
    │   ├── nacos-logback.xml
    │   └── schema.sql
    ├── plugins
    └── standalone-logs
  • docker-compose.yml
version: '3'

services:
  mysqlnacos:
    image: nacos/nacos-mysql:5.7
    container_name: mysq-nacos
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: yqKlmgs1cl
      MYSQL_DATABASE: nacos
      MYSQL_USER: nacos
      MYSQL_PASSWORD: liubei@2021
    ports:
      - 3306:3306
    volumes:
      - ./mysql/data/:/var/lib/mysql/
      - ./mysql/my.cnf:/etc/mysql/my.cnf
  nacos:
    image: nacos/nacos-server
    container_name: nacos
    restart: always
    depends_on:
      - mysqlnacos
    environment:
      NACOS_AUTH_ENABLE: "true"
      SPRING_DATASOURCE_PLATFORM: mysql
      MODE: standalone
      NACOS_REPLICAS: 1
      MYSQL_SERVICE_HOST: mysqlnacos
      MYSQL_SERVICE_DB_NAME: nacos
      MYSQL_SERVICE_PORT: 3306
      MYSQL_SERVICE_USER: nacos
      MYSQL_SERVICE_PASSWORD: liubei@2021
      NACOS_APPLICATION_PORT: 8848
      NACOS_SERVER_PORT: 8848
      PREFER_HOST_MODE: hostname
    volumes:
      - ./nacos/standalone-logs:/home/nacos/logs
      - ./nacos/plugins:/home/nacos/plugins
      - ./nacos/conf:/home/nacos/conf
      - ./nacos/data:/home/nacos/data
    ports:
      - "80:8848"

  • my.cnf
[mysqld]
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
datadir         = /var/lib/mysql
secure-file-priv= NULL
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

# Custom config should go here
!includedir /etc/mysql/conf.d/
  • nacos/conf
    这些配置文件可以先启动一次容器,然后从容器中用docker cp命令拷贝到nacos/conf目录下

【Nacos】docker-compose 一键启动 nacos_第2张图片

你可能感兴趣的:(#,#,常用服务-未分类,nacos,docker-compose,docker)