gpt4 book ai didi

amazon-web-services - docker-compose.yaml 定义的 AWS ECS 任务的软内存限制

转载 作者:行者123 更新时间:2023-12-02 18:28:18 24 4
gpt4 key购买 nike

Amazon 提供了ecs-cli compose 命令可以从docker-compose.yaml 中设置任务定义

但我无法为此类任务声明内存限制(尤其是软内存限制)。不支持部署选项。

Skipping unsupported YAML option for service...  option name=deploy 

有没有办法用 compose 实现这个?或者是使用 compose 坏主意,最好使用 native 任务定义。

更新我的撰写文件被请求,这是它

version: '3'

services:
worker:
image: 880289074637.dkr.ecr.us-east-1.amazonaws.com/negative-keywords:latest
env_file: .env
command: ["celery", "-A", "negmatch", "worker", "-l", "info"]
deploy:
resources:
limits:
cpus: '0.50'
memory: 256M
reservations:
cpus: '0.25'
memory: 128M
web:
image: 880289074637.dkr.ecr.us-east-1.amazonaws.com/negative-keywords:latest
env_file: .env
ports:
- "80:8000"
depends_on:
- "worker"
deploy:
resources:
limits:
cpus: '0.50'
memory: 256M
reservations:
cpus: '0.25'
memory: 128M

最佳答案

您将需要使用 v2 的 docker compose 来设置这些值。

截至今天,根据 docker docs , deploy 仅用于群模式部署。

Looking for options to set resources on non swarm mode containers?

The options described here are specific to the deploy key and swarm mode. If you want to set resource constraints on non swarm deployments, use Compose file format version 2 CPU, memory, and other resource options. If you have further questions, refer to the discussion on the GitHub issue docker/compose/4513.

有关使用 v2 与 v3 的更多信息。 https://github.com/docker/compose/issues/4513#issuecomment-377311337

这是示例 docker-compose(v2),它对任务的容器定义设置了软内存和硬内存限制。 mem_limit 是硬限制,mem_reservation 是软限制。

命令 -

ecs-cli compose --project-name nginx --file docker-compose.yaml create

撰写文件 -

version: '2'
services:
nginx:
image: "nginx:latest"
mem_limit: 512m
mem_reservation: 128m
cpu_shares: 0
ports:
- 80

enter image description here

关于amazon-web-services - docker-compose.yaml 定义的 AWS ECS 任务的软内存限制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55304637/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com