Docker 服务编排 快速部署 SpringCloud 项目 (一)
一、docker-compose.yml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | version: "3.3" networks: zeal: volumes: data: services: gateway: restart: always build: context: ./gateway dockerfile: Dockerfile container_name: zeal_gateway #指定容器名称 ports: - "8222:8222" networks: - zeal zeal_acl: build: context: ./zeal_acl dockerfile: Dockerfile container_name: zeal_acl #指定容器名称 ports: - "8009:8009" networks: - zeal nacos: restart: always image: nacos/nacos-server:latest ports: - "8848:8848" environment: - "MODE=standalone" networks: - zeal mysql: restart: always image: daocloud.io/library/mysql: 5.6 . 20 #指定镜像路径 container_name: mysql #指定容器名称 ports: - "3306:3306" #只写一个端口随机使用宿主机一个端口进行容器端口映射 environment: - "MYSQL_ROOT_PASSWORD=root" - "TZ=Asia/Shanghai" - "MYSQL_DATABASE=zeal_acl" volumes: - /apps/conf/mysql:/var/lib/mysql #映射数据卷 - /apps/db/zeal_acl/zeal_acl_db.sql:/docker-entrypoint-initdb.d/zeal_acl_db.sql networks: - zeal sentinel1: restart: always image: redis container_name: redis-sentinel- 1 command: redis-sentinel /apps/conf/redis/conf/sentinel1.conf # 自定义路径,可更改,但是需要和volumes中的路径相同。 restart: always ports: - 26380 : 26380 volumes: - ./apps/conf/redis/conf/sentinel1.conf:/apps/conf/redis/conf/sentinel1.conf # 自定义路径,可更改,但是需要和command中的路径相同。 networks: - zeal sentinel2: restart: always image: redis container_name: redis-sentinel- 2 command: redis-sentinel /apps/conf/redis/conf/sentine2.conf restart: always ports: - 26381 : 26381 volumes: - ./apps/conf/redis/conf/sentinel2.conf:/apps/conf/redis/conf/sentine2.conf networks: - zeal sentinel3: restart: always image: redis container_name: redis-sentinel- 3 command: redis-sentinel /apps/conf/redis/conf/sentine3.conf restart: always ports: - 26382 : 26382 volumes: - ./apps/conf/redis/conf/sentinel3.conf:/apps/conf/redis/conf/sentine3.conf networks: - zeal |
二、Dockerfile
FROM openjdk:8 ENV APP_HOME=/apps WORKDIR $APP_HOME COPY api_gateway-1.0-SNAPSHOT.jar api_gateway.jar EXPOSE 8222 ENTRYPOINT ["java","-jar"] CMD ["api_gateway.jar"]
三、部署注册中心 配置中心 Nacos
docker-compose up -d nacos
四、部署网关 Gateway
1 | docker-compose up -d gateway |
成功注册
五、部署MySql
docker-compose up -d mysql
六、部署Redis 哨兵模式
docker-compose up -d sentinel1 docker-compose up -d sentinel2 docker-compose up -d sentinel3
七、部署业务服务
docker-compose up -d zeal_acl
SUCCESS!!!!!
本文作者:KwFruit
本文链接:https://www.cnblogs.com/mangoubiubiu/p/17116206.html
版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
2022-02-13 Docker 安装 ELK
2022-02-13 修改VirtualBox虚拟机默认存储路径及虚拟机迁移