限制 docker-compose v3 中的资源 [英] Limit resources in docker-compose v3

查看:104
本文介绍了限制 docker-compose v3 中的资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

docker-compose.yml 文件的第 3 版不再支持 mem_limit.文档告诉我应该使用 deploy.resources 键代替,而且这部分只对 swarm 或 docker stack 有效.

mem_limit is no longer supported in version 3 of docker-compose.yml file. The documentation tells that I should use the deploy.resources key instead but also that this part will only be effective with swarm or docker stack.

cpu_shares、cpu_quota、cpuset、mem_limit、memswap_limit:这些已经被deploy 下的resources key 替换了.注意,deploy 配置只在使用 docker stack deploy 时生效,被 docker-compose 忽略.

cpu_shares, cpu_quota, cpuset, mem_limit, memswap_limit: These have been replaced by the resources key under deploy. Note that deploy configuration only takes effect when using docker stack deploy, and is ignored by docker-compose.

... 如所写文档.

如何使用 yml 文件的 v3 格式使用 docker-compose 设置内存/cpu 限制?

How do I set memory/cpu limits with docker-compose with v3 format of the yml file?

推荐答案

我也在想同样的事情,结果发现:https://github.com/docker/compose/issues/4513

I was wondering the same thing and found this: https://github.com/docker/compose/issues/4513

简而言之,这是不可能的,您必须使用 docker-compose 格式的 2.1 版才能指定docker-compose up

So in short it's just not possible to do that, you have to use the version 2.1 of the docker-compose format to be able to specify limits that are not ignored by docker-compose up

这篇关于限制 docker-compose v3 中的资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆