我尝试以非群模式在docker-compose文件中设置内存限制。这是我的docker-compose文件
version: "3.5"
services:
model:
image: ...
container_name: ...
env_file: ./.env
command: ...
network_mode: host
mem_reservation: 30000000
ports:
- ...
但它抱怨如下
ERROR: The Compose file '././docker-compose.yaml' is invalid because:
Unsupported config option for services.model: 'mem_reservation'
这是怎么了?
答案 0 :(得分:0)
这不是限制内存的方式。您必须通过在“部署”小节下添加限制来限制它。检查此Yaml中的mongo。
version: "3.3"
services:
mongo:
image: mongo:4
deploy:
resources:
limits:
memory: 2g
运行
docker-compose --compatibility -d up