As the title of this question suggests I'm wanting to set max disk/memory and cpu usage for a container using docker (docker.io).
Is there a way to do this using just docker?
As the title of this question suggests I'm wanting to set max disk/memory and cpu usage for a container using docker (docker.io).
Is there a way to do this using just docker?
Note: PR 15078 is implementing (Dec. 2015) support for changing resources both for stopped and running container (possibly docker 1.10 ou 1.11)
Note that making changes via
docker set
should persist.I.e., those changes would be permanent (updated in the container's JSON)
Memory/CPU
Docker now supports more resource allocation options:
Have a look at
docker run --help
for more details.If you use lxc backend (
docker -d --exec-driver=lxc
), more fine grained resource allocation schemes can be specified, e.g.:Storage
Limiting storage is a bit trickier at the moment. Please refer to the following links for more details:
Just a note about
-m / --memory
--If you are setting the memory limit but the container is not allocating the amount of memory you are trying to reserve, go into the preferences and adjust the memory being reserved to the docker app as a whole.
I ran into this 'problem' on OS X and wasn't sure why my container was being limited to ~2G when I was specifying
--memory=8g
see this gist: https://gist.github.com/afolarin/15d12a476e40c173bf5f
1) You an give a relative share of the cpus with --cpu-share='relative-number'
2) you can now put hard limits on cpus:
if using LXC instead of the default libcontainer then you can also specify this in:
RAM:
You can now allocate a number of CPU shares to a container with the -c option as described here
You can pass only memory limit (i.e. 5MB limit: docker run -m=5242880 ...image) as I know. But guys from docker.io planed to add CPU limits.