How to limit amount of running docker instances?
I am using one machine to host docker and launch containers on demand for other machines. However my resources are not unlimited and machines making those requests don’t have any knowledge about other requests. I’d like to limit the amount of containers that my docker host can launch to a certain amount. How can I achieve that?
One Solution collect form web for “How to limit amount of running docker instances?”
The only way I know is to write a or monitor which implements your business rules.
That is, something that either:
- intercepts the calls to the docker daemon and only lets a certain amount of RAM or number of processes start, OR
- a separate daemon that listens to docker daemon events and kills containers when there are too many.
There might also be some hook in the kernel to place limits on the number of cgroups/namespaces created, but I don’t know the calls offhand.