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:
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. Where is the Problem? is the host machine (debian 11) not supporting it? or the node:alpine-16 source?
Thanks a lot for clarification what the Problem could be ;)
Cheers
CodePudding user response:
There is no such variable CGROUP_CONF
. cgroups does not know it.
Normally you leave it up to the operator what resources they want to give the container. Docker has runtime options for this.
docker run --memory 256Mi --cpus 2