Search code examples
dockercgroups

How to resize docker container's cpu-share value dynamiclly?


I am using docker 1.11, I run a container like:

sudo docker run -it --rm --cpu-shares 4 zeroboh/stress --cpu 2

I want to change cpu-shares's value while docker container keeps running. Is there any method to do so?

I tried to edit file /sys/fs/cgroup/cpu/docker/[containerID]/cpu.shares with VIM, but failed for "Fsync failed". It means I can't modify cgroup file directly?


Solution

  • I think docker update is the way to go. Could look like this (taken from referenced documentation)
    $ docker update --cpu-shares 512 abebf7571666