简体   繁体   English

如何在 docker 中使用 cgroup_conf?

[英]how to use cgroup_conf in docker?

i want to limit Memory & CPU usage a docker container can consume by ENV CGROUP_CONF memory:75%;cpu:10% inside the container runs a nodejs api with a docker file like so:我想限制 Memory 和 CPU 使用率 docker 容器可以通过ENV CGROUP_CONF memory:75%;cpu:10%在容器内运行 nodejs api 和 docker 文件,如下所示:

FROM node:16-alpine
WORKDIR /usr/src/app
COPY package*.json ./
ENV CGROUP_CONF memory:75%;cpu:10% 

RUN npm install
RUN .........

COPY . .    
EXPOSE 3000
CMD [ "node","--experimental-specifier-resolution", "node", "--loader", "ts-node/esm", "src/app.ts" ]

but somehow the cgroup thing does not work.但不知何故,cgroup 的东西不起作用。 Where is the Problem?问题出在哪儿? is the host machine (debian 11) not supporting it?主机(debian 11)不支持它吗? or the node:alpine-16 source?或 node:alpine-16 来源?

Thanks a lot for clarification what the Problem could be;)非常感谢您澄清问题可能是什么;)

Cheers干杯

There is no such variable CGROUP_CONF .没有这样的变量CGROUP_CONF cgroups does not know it. cgroups 不知道。

Normally you leave it up to the operator what resources they want to give the container.通常情况下,您可以让操作员决定他们想要为容器提供什么资源。 Docker hasruntime options for this. Docker 有运行时选项

docker run --memory 256Mi --cpus 2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM