docker-compose部署nacos单机版(简洁优化版)
Posted 小寒2020
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了docker-compose部署nacos单机版(简洁优化版)相关的知识,希望对你有一定的参考价值。
docker-compose部署nacos单机版(简洁优化版)
预览#
初始化数据库#
mysql 文件:
https://github.com/Gleans/SpringCloudPro/blob/master/docker/mysql-init/init.sql
docker-compose 启动 nacos 单机版#
- Linux安装Docker(CentOS 8)与docker-compose套装
- windows安装Docker与docker-compose套装
- MacBook 安装 Docker 与 docker-compose 套装
docker-compose.yml
# 启动命令
# docker-compose --compatibility up -d
version: \'3\'
services:
mysql5.7:
image: mysql:5.7
container_name: mysql57
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: nacos
MYSQL_USER: root
MYSQL_PASSWORD: root
ports:
- 3306:3306
volumes: # 挂载持久化地址(个人理解)
- ./docker/mysql/:/var/lib/mysql/
- ./docker/conf/:/etc/mysql/
nacos:
image: nacos/nacos-server:1.2.1
container_name: nacos
restart: always
depends_on:
- mysql5.7
environment:
PREFER_HOST_MODE: hostname #如果支持主机名可以使用hostname,否则使用ip,默认也是ip
SPRING_DATASOURCE_PLATFORM: mysql #数据源平台 仅支持mysql或不保存empty
MODE: standalone
MYSQL_SERVICE_HOST: mysql5.7
MYSQL_SERVICE_DB_NAME: nacos
MYSQL_SERVICE_PORT: 3306
MYSQL_SERVICE_USER: root
MYSQL_SERVICE_PASSWORD: root
NACOS_APPLICATION_PORT: 9999
JVM_XMS: 512m
JVM_MMS: 320m
volumes:
- ./docker/nacos/standalone-logs/:/home/nacos/logs
- ./docker/nacos/plugins/:/home/nacos/plugins
- ./docker/nacos/conf/application.properties:/home/nacos/conf/application.properties
ports:
- "9999:9999"
prometheus:
container_name: prometheus
image: prom/prometheus:latest
volumes:
- ./docker/nacos/prometheus/prometheus-standalone.yaml:/etc/prometheus/prometheus.yml
ports:
- "9090:9090"
depends_on:
- nacos
restart: on-failure
grafana:
container_name: grafana
image: grafana/grafana:latest
ports:
- 3000:3000
restart: on-failure
上面挂载的文件以及 volumes
都在 Github
配置已经在 Windows
以及 Mac_OS
实测通过的
地址:https://github.com/Gleans/SpringCloudPro/tree/master/docker
启动#
docker-compose --compatibility up -d
打印日志,我这里是已经启动过了
D:\\workspaces\\SpringCloudPro>docker-compose --compatibility up -d
mysql57 is up-to-date
grafana is up-to-date
Recreating rabbitmq ...
redis is up-to-date
nacos is up-to-date
Recreating rabbitmq ... done
up-to-date
代表你可以修改一些配置然后运行docker-compose --compatibility up -d
命令,它只会更新重启你修改的容器,就很人性化
访问web#
地址:http://127.0.0.1:9999/nacos/#/login
默认帐户与登录密码:
- 账号:nacos
- 密码:nacos
到此,docker-compose
启动nacos
单机版完成
以上是关于docker-compose部署nacos单机版(简洁优化版)的主要内容,如果未能解决你的问题,请参考以下文章