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

标签 amazon-web-services docker docker-compose amazon-ecs

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/

相关文章:

Docker:引起:java.nio.file.FileSystemException:./conf/flow.xml.gz:资源忙

amazon-web-services - Golang S3铲斗尺寸

java - 无法从 Amazon EC2 ubuntu 16.04 镜像连接到 Amazon RDS 上的数据库

docker - 将Docker镜像推送到Google Container Registry时,导致身份验证错误的原因是什么?

ruby-on-rails - 因为出现部署错误,所以我想做点什么

docker-compose - Hyperledger - MSP 错误 : the supplied identity is not valid: x509: certificate signed by unknown authority

amazon-web-services - 在 CloudFormation 中的多个 LoadBalancer 后面添加实例?

python - 以编程方式登录亚马逊

docker - 在Nginx反向代理后面的docker-compose服务中请求时axios ECONNREFUSED

docker - 从主机解析 docker-compose 容器名称