zoukankan      html  css  js  c++  java
  • Compose 编排 SpringCloud微服务

    Compose 编排 SpringCloud微服务

    • 将 Eureka 等微服务运行在 Docker 容器中
    • docker-compose 编排文件的编写
    • 通过 Docker Compose 启动、停止

     现在我们开始学习如何通过 Docker-Compose 组合编排运行多个微服务。

    将 Eureka 等微服务运行在 Docker 容器中

    • 构建 Eureka Server 镜像
    cd microservice-eureka-server
    mvn clean package -DskipTests && mvn dockerfile:build
    • 构建用户服务镜像
    cd microservice-provider-user
    mvn clean package -DskipTests && mvn dockerfile:build
    

      

    • 构建电影服务镜像
     
    cd microservice-consumer-movie
    mvn clean package -DskipTests && mvn dockerfile:build
    

      

    • 查看镜像
    docker images
    

      

    会发现如下三个镜像:

    REPOSITORY                                 TAG                 IMAGE ID            CREATED              SIZE
    microservice-consumer-movie                0.0.1-SNAPSHOT      20c107a27dc3        44 seconds ago       139MB
    microservice-provider-user                 0.0.1-SNAPSHOT      5d9c9d1e959a        About a minute ago   139MB
    microservice-eureka-server                 0.0.1-SNAPSHOT      5621f990e5d5        4 minutes ago        128MB
    

      

     docker-compose.yml
    root@ubuntu:/home/tom/Desktop/3/docker2# cat docker-compose.yml 
    version: '3.3'
    services:
      eureka-server:
        image: eureka-server:latest 
        container_name: eureka-server
        restart: always
        ports:
          - 8761:8080
      user-service:
        image: provider-user:latest 
        container_name: user-service
        depends_on:
          - eureka-server
        links:
          - eureka-server
        restart: always
        environment:
          EUREKA_URL: http://eureka-server:8761/eureka
        ports:
          - 8000:8000
      consumer-movie-feign:
        image: consumer-movie-feign:1.0 
        container_name: consumer-movie-feign
        depends_on:
          - eureka-server
        links:
          - eureka-server
        restart: always
        environment:
          EUREKA_URL: http://eureka-server:8761/eureka
        ports:
          - 8011:8011
    

      

    菜鸟的自白
  • 相关阅读:
    Java基础
    数据库表设计
    Spring循环依赖
    Mysql类型转换
    Mysql刷题
    JavaScript
    Git
    告别.NET生成报表统计图的烦恼
    JS给页面标签添加事件(或超链接链接)
    发现联想手机P630型号的一个严重的系统Bug
  • 原文地址:https://www.cnblogs.com/lzjloveit/p/14426835.html
Copyright © 2011-2022 走看看