I do know that we can create a container with memory limitation like this
docker run -ti --memory-reservation 1G ubuntu:14.04 /bin/bash
but how to update the limitation of memory/CPU for existing container?
Set Maximum Memory Access To limit the maximum amount of memory usage for a container, add the --memory option to the docker run command. Alternatively, you can use the shortcut -m . Within the command, specify how much memory you want to dedicate to that specific container.
The maximum amount of memory the container can use. If you set this option, the minimum allowed value is 6m (6 megabytes). That is, you must set the value to at least 6 megabytes.
The --memory parameter limits the container memory usage, and Docker will kill the container if the container tries to use more than the limited memory.
Docker Update Command
docker update --memory "1g" --cpuset-cpu "1" <RunningContainerNameOrID>
this will update the "RunningContainerNameOrId" to use 1g of memory and only use cpu core 1
To up date all running containers to use core 1 and 1g of memory:
docker update --cpuset-cpus "1" --memory "1g" $(docker ps | awk 'NR>1 {print $1}')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With