docker安装
【centos】【docker】安装启动
docker-compose安装
【docker-compose】安装使用文章来源:https://www.toymoban.com/news/detail-681089.html
配置文件
version: '2'
networks: #自定义网络myapp,为了只有这些服务可以在该网络内相互访问
myapp:
driver: bridge
services: #将容器抽象成服务
nacos: #注册中心
image: nacos/nacos-server:latest
container_name: nacos
restart: always
environment:
MODE: standalone
PREFER_HOST_MODE: ip
SPRING_DATASOURCE_PLATFORM: mysql
MYSQL_SERVICE_HOST: 【ip地址】#数据库在外部
MYSQL_SERVICE_PORT: 3306
MYSQL_SERVICE_DB_NAME: nacos_config
MYSQL_SERVICE_USER: nacos
MYSQL_SERVICE_PASSWORD: Nacos@123456
# MYSQL_SERVICE_DB_PARAM: characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&allowPublicKeyRetrieval=true&serverTimezone=GMT%2B8
volumes:
- ./docker/nacos/standalone-logs/:/home/nacos/logs
ports:
- "8848:8848"
networks:
- myapp
sentinel: #熔断限流
image: bladex/sentinel-dashboard
container_name: sentinel-nacos
restart: always
depends_on:
- nacos
environment:
NACOS_SERVER_ADDR: nacos:8848
NACOS_USERNAME: nacos
NACOS_PASSWORD: nacos
NACOS_NAMESPACE: public
NACOS_GROUP_ID: SENTINEL_GROUP
ports:
- "8858:8858"
networks:
- myapp
gateway: #网关
image: nacos-gateway
container_name: nacos-gateway
restart: always
depends_on:
- nacos
ports:
- "18890:18890"
environment:
- spring.cloud.nacos.discovery.server-addr=nacos:8848
- spring.cloud.sentinel.transport.dashboard=sentinel:8858
networks:
- myapp
authserver: #认证中心
image: nacos-authserver
container_name: nacos-authserver
restart: always
depends_on:
- nacos
environment:
- spring.datasource.url=jdbc:mysql://10.1.58.5:3306/oauth?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=CTT
- spring.cloud.nacos.discovery.server-addr=nacos:8848
- spring.cloud.sentinel.transport.dashboard=sentinel:8858
- JAVA_OPTS=-Dlog4j2.formatMsgNoLookups=true
networks:
- myapp
nacos-handheld: #业务后台接口
image: nacos-handheld
container_name: nacos-handheld
restart: always
depends_on: #gateway、authserver服务启动后本服务才启动
- gateway
- authserver
environment: #springcloud项目application.yml配置修改
- spring.datasource.url=jdbc:mysql://10.1.58.5:3306/handled?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=CTT
- spring.profiles.active=prod
- spring.cloud.nacos.discovery.server-addr=nacos:8848
- security.oauth2.resource.user-info-uri=http://gateway:18890/nacos-authserver/oauth/check_token
- JAVA_OPTS=-Dlog4j2.formatMsgNoLookups=true
networks:
- myapp
handheld-front: #业务前端平台
image: handheld-front
container_name: handheld-front
restart: always
depends_on:
- gateway
- authserver
links: #传递gateway服务ip地址到本容器,用于nginx反向代理配置使用gateway代替实际ip
- gateway
ports: #将端口暴露至宿主机的8089
- "8089:80"
networks:
- myapp
启动docker-compose配置文件文章来源地址https://www.toymoban.com/news/detail-681089.html
docker-compose up -d
到了这里,关于【nacos】【sentinel】【gateway】docker-compose安装及web项目部署的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!