Search code examples
memorydockercontainers

Update the limitation of memory/CPU for existing container in docker


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?


Solution

  • Docker Update Command

    docker update --memory "1g" --cpuset-cpus "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}')