问题描述
我无法指定CPU&内存用于版本3中指定的服务。
对于版本2,它与 mem_limit&服务下的 cpu_shares参数。但是在使用版本3时它失败了,除非我使用群体模式,否则将它们置于部署部分似乎不值得。
有人可以帮忙吗?
版本: 3
服务:
节点:$ b $ b构建:
上下文:。
dockerfile:./docker-build/Dockerfile.node
重新启动:始终
环境:
-VIRTUAL_HOST = localhost
卷:
-日志:/ app / out /
公开:
-8083
命令:[ npm, start]
cap_drop:
-NET_ADMIN
-SYS_ADMIN
我知道这个话题有点老了,看起来很陈旧,但无论如何,我还是可以使用以下选项:
部署:
资源:
限制:
cpus: '0.001'
内存:使用3.7版的docker-compose $ b $时,5000万美元
b
对我而言有帮助的是使用以下命令:
docker-compose --compatibility up
-兼容性
标志代表(摘自文档):
这很好,我不必将docker-compose文件恢复到v2。
I am unable to specify CPU & memory for services specified in version 3 .
With version 2 it works fine with "mem_limit" & "cpu_shares" parameters under the services . But it fails while using version 3 , putting them under deploy section doesn't seem worthy unless i am using swarm mode .
Can somebody help ?
version: "3"
services:
node:
build:
context: .
dockerfile: ./docker-build/Dockerfile.node
restart: always
environment:
- VIRTUAL_HOST=localhost
volumes:
- logs:/app/out/
expose:
- 8083
command: ["npm","start"]
cap_drop:
- NET_ADMIN
- SYS_ADMIN
I know the topic is a bit old and seems stale, but anyway I was able to use these options:
deploy:
resources:
limits:
cpus: '0.001'
memory: 50M
when using 3.7 version of docker-compose
What helped in my case, was using this command:
docker-compose --compatibility up
--compatibility
flag stands for (taken from the documentation):
Think it's great, that I don't have to revert my docker-compose file back to v2.
这篇关于如何指定内存和泊坞窗撰写版本3中的CPU限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!