A
A
at0m1x2020-05-25 00:15:10
Docker
at0m1x, 2020-05-25 00:15:10

How to limit memory and cpu in docker?

There is a project in PHP, there is a docker-compose config for it. For this project, Docker is used only to run the same LAMP environment locally on the developers' computers. Those. using the command:
docker-compose -f ../../docker-compose.yml up -d

But the problem is that one of the containers, the one in which Apache and PHP run, gradually eats up all the computer's RAM to the limit. At the same time, no background PHP scripts are running. Why this happens is unknown, it looks like a memory leak, either in PHP, or in Apache ...

Is it possible to limit the use of RAM and CPU by Docker, globally for all containers, or for individual ones?

Is it possible to set this restriction through any Docker configs itself, or through the docker-compose config?

Options:
CGroups - but I haven't figured out exactly how yet.
Create a virtual machine and run Docker containers on it - higher than the resources of the Docker virtual machine will not climb.
In the docker-compose config in the deploy section, but this option is probably not suitable, because. used by Docker only locally to set up the LEMP environment.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sanes, 2020-05-25
@Sanes

used by Docker only locally to set up the LEMP environment

Why limit something there? Customize PHP-FPM if you like. It doesn't even make sense. Do you have a lot of traffic on LAN?

R
Ranwise, 2020-05-25
@Ranwise

https://docs.docker.com/config/containers/resource...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question