docker-compose scale

news/2024/10/4 21:24:54/文章来源:https://www.cnblogs.com/lightsong/p/18274245

docker-compose scale

配置

 https://github.com/docker/compose/issues/5586

version: '2.2'
services:template:image: tutum/hello-worldscale: 2
version: "3"
services:pg:image: postgres:latestnetworks:default:aliases:- rdb.test.mepgadmin:image: dpage/pgadmin4:latestdeploy:replicas: 3environment:HOSTNAME: rdba.test.mePGADMIN_DEFAULT_EMAIL: user@test.mePGADMIN_DEFAULT_PASSWORD: SuperSecret

命令

https://noobtomaster.com/docker/running-and-scaling-applications-using-compose/#:~:text=Scaling%20your%20application%20becomes%20effortless%20with%20Docker%20Compose.,it%20to%20three%20containers%3A%20docker-compose%20up%20--scale%20web%3D3

version: '3'
services:web:build: .ports:- "8080:80"volumes:- ./app:/usr/share/nginx/htmldb:image: mysqlenvironment:- MYSQL_ROOT_PASSWORD=secret

 

docker-compose up
docker-compose up --scale web=3

 

microservice-demo -- scale config

 https://github.com/fanqingsong/microservice-demo

version: '2'services:gateway:build: traefikcommand: --api --providers.docker --tracing.instana.logLevel="DEBUG" --accesslog # Enables the web UI and tells Traefik to listen to dockernetworks:- microservicesports:- "80:80"# - "443:443"- "9090:8080"volumes:- /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker eventsuser:build: usernetworks:- microservices# ports:#   - "8081:80"cart:build: cartnetworks:- microservices# ports:#   - "8082:80"product:build: productnetworks:- microservices# ports:#   - "8083:80"event:build: eventnetworks:- microservices# ports:#   - "8084:80"web:build: webnetworks:- microservices
    scale: 2# ports:#   - "8085:80"networks:microservices:driver: bridge

启动

 测试

 

traefic demo

scale动态扩展, 扩展容器会自动注册到 traefic

https://github.com/vegasbrianc/docker-compose-demo/tree/master

version: '3'
services:whoami:image: containous/whoami # A container that exposes an API to show its IP address
    labels:- "traefik.frontend.rule=Host:whoami.docker.localhost"redis:image: redisnetworks:- back-tierreverse-proxy:image: traefik command: --api --providers.docker --tracing.instana.logLevel="DEBUG" --accesslog # Enables the web UI and tells Traefik to listen to dockerports:- "80:80"     # The HTTP port- "8080:8080" # The Web UI (enabled by --api)volumes:- /var/run/docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker eventsnetworks:front-tier:driver: bridgeback-tier:driver: bridge

 

Scaling

Now comes the fun part of compose which is scaling. Let's scale our web service from 1 instance to 5 instances. This will now scale our web service container. We now should run an update on our stack so the Loadbalancer is informed about the new web service containers.

docker-compose scale whoami=5
 

Now run our curl command again on our web services and we will now see the hostname change. To get a deeper understanding tail the logs of the stack to watch what happens each time you access your web services.

```
docker-compose logs whoami
whoami_5         | Starting up on port 80
whoami_4         | Starting up on port 80
whoami_3         | Starting up on port 80
whoami_2         | Starting up on port 80
whoami_1         | Starting up on port 80
```
 

Here's the output from my docker-compose logs after I curled the whoami application so it is clear that the round-robin is sent to all 5 web service containers.

```
reverse-proxy_1  | 172.26.0.1 - - [01/May/2019:19:16:34 +0000] "GET /favicon.ico HTTP/1.1" 200 647 "http://whoami.docker.localhost/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36" 10 "Host-whoami-docker-localhost-1" "http://172.26.0.2:80" 1ms
```

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/733022.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Tiny-NewsRec论文阅读笔记

Tiny-NewsRec: Effective and Efficient PLM-based News Recommendation论文阅读笔记 Abstract 存在的问题: ​ 现有的大多数工作只是根据新闻推荐任务对 PLM 进行微调,这可能会受到预训练语料库和下游新闻文本之间已知领域偏移问题的影响。此外,PLM 通常包含大量参数,计算…

Ros slam 之行自主导航

经过前面三节的铺垫,我们只需要再编写一个launch文件启动nav2就可以让fishbot自己动起来了。1.编写launch文件我们将地图、配置文件传递给nav2为我们提供好的launch文件中即可。再一个launch文件中包裹另一个功能包中的luanch文件采用的是IncludeLaunchDescription和PythonLau…

pip install jedi 失败

报错内容: ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: C:\\Users\\Administrator\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-package…

米尔瑞芯微创新设计RK3568全LGA国产核心板,更紧凑可靠

今天,米尔电子发布MYC-LR3568核心板及开发板,核心板基于高性能、低功耗的国产芯片-瑞芯微RK3568。核心板采用LGA 创新设计,可实现100%全国产自主可控。MYC-LR3568系列核心板采用高密度高速电路板设计,在大小为43mm*45mm*3.85mm板卡上集成了RK3568J/RK3568B2、LPDDR4、eMMC、…

k8s 概念

Ref https://www.tigera.io/blog/key-kubernetes-concepts/

ConcurrentHashMap底层原理

一、ConcurrentHashMap底层结构二、ConcurrentHashMap类的成员变量public class ConcurrentHashMap<K, V>extends AbstractMap<K, V>implements ConcurrentMap<K, V>, Serializable {// 数组最大容量private static final int MAXIMUM_CAPACITY = 1 <<…

Compute Shader

Compute Shader 是一种高级功能,用于在 GPU 上执行并行计算任务。它非常适合处理大量数据,执行复杂的数学计算,或在高性能图形处理中使用。 常用于,需要密集的并行多线程计算,CPU不擅长并行计算,丢给GPU去算,然后把结果返回给CPU,或者直接渲染到屏幕上。 需要图形API,…

指数增强策略:如何通过动态调整权重击败沪深300?

哈喽,大家好,我是木头左!今天,将深入探讨一种特定的指数增强策略,这种策略以0.8为初始权重跟踪沪深300中权重大于0.35%的成份股,并根据个股的表现动态调整权重。让一起启航,探索这一策略如何帮助在波动的市场中稳健前行。 策略概述:权重与表现的舞蹈 在传统的指数跟踪策…

IP地址的概念及IP子网划分

十进制与二进制的转换192. 168. 10. 111000000 10101000 00001010 00000001幂27 26 25 24 23 22 21 20128 64 32 16 8 4 2 1位1 1 0 0 0 0 0 0=128+64=192 IP地址的划分网络掩码(Network Mask)IP地址类型 1)网络地址:用于标识一个网络,主机位全0的地址。 2)广播地址:用于…

远程控制软件哪个好用?精选安全远控软件ToDesk

远程控制软件的妙用,对于打工人来说莫过于能快速处理下班后的紧急工作。即使远在千里,也能毫无障碍远控办公电脑,不需要随身携带笔记本,也不用受限于地点。 但市面上远程控制软件良莠不齐,而且有些软件还时不时掉链子,在远控安全方面也有所顾虑,怎样才能火眼金睛找到最适…

旧手机、平板不再吃灰,装上ToDesk秒变办公利器

家里有好久用不到却又不舍得处理的手机、平板怎么办?教你一招,包你高效利用旧设备,轻轻松松为工作、学习、娱乐等方面都赋能! 操作方法很简单,仅需要在以往不用以及当前常用的各个设备中都装上ToDesk远程控制软件便能更实用。通过巧妙利用,它不仅能够帮助用户将旧手机或平…

ToDesk云电脑游戏数量?高性能显卡云桌面

玩游戏最怕遇到电脑配置跟不上,操作卡成狗不说,画面还一卡卡的,游戏体验极差。 最近被人安利了ToDesk的云电脑,可能是刚推出的,配置价格都很能打,浅用了一波拿来打APEX和荒野大镖客,体验有点惊喜到我!用ToDesk云电脑来打游戏,还不需要浪费时间在安装游戏上,多达数百种…