【nacos】【sentinel】【gateway】docker-compose安装及web项目部署

docker安装

【centos】【docker】安装启动

docker-compose安装

【docker-compose】安装使用

配置文件

yaml 复制代码
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配置文件

bash 复制代码
docker-compose up -d
相关推荐
微刻时光5 分钟前
Docker部署Nginx
运维·nginx·docker·容器·经验
陈小肚27 分钟前
k8s 1.28.2 集群部署 docker registry 接入 MinIO 存储
docker·容器·kubernetes
A陈雷44 分钟前
springboot整合elasticsearch,并使用docker desktop运行elasticsearch镜像容器遇到的问题。
spring boot·elasticsearch·docker
.生产的驴1 小时前
SpringCloud Gateway网关路由配置 接口统一 登录验证 权限校验 路由属性
java·spring boot·后端·spring·spring cloud·gateway·rabbitmq
小扳1 小时前
Docker 篇-Docker 详细安装、了解和使用 Docker 核心功能(数据卷、自定义镜像 Dockerfile、网络)
运维·spring boot·后端·mysql·spring cloud·docker·容器
南猿北者9 小时前
docker Network(网络)
网络·docker·容器
sam-12311 小时前
k8s上部署redis高可用集群
redis·docker·k8s
Fanstay98511 小时前
在Linux中使用Nginx和Docker进行项目部署
linux·nginx·docker
death bell13 小时前
Docker基础概念
运维·docker·容器
天幕繁星14 小时前
docker desktop es windows解决vm.max_map_count [65530] is too low 问题
windows·elasticsearch·docker·docker desktop