Docker Community Forums

Share and learn in the Docker community.

Memory & CPU allocation for containers


I have a CentOS 7 machine with 12GB of memory & 8 core CPU. I have deployed multiple CentOS containers from docker hub, each running a small application.

I have not specified any memory or CPU parameters as part of the docker run command. How will docker allocate memory & CPU to the containers & manage the requirements for each container.

Is there any documentation/wiki link available which describes the algorithm used by docker?

Bhushan Pathak

See document on docker run command. especially --cpus and --memory.

By default, docker does not restrict the container by cpu or memory.

So if docker does not restrict CPU & Memory access, so each docker container gets what it requests for when the container is launched [provided the resources are available].

What will happen if a container requests for more memory resource, say an hour after it is launched, assuming the application within the container is under peak load to serve requests.

Bhushan Pathak

it will throw an OOME error

It will result in OOM kills of random processes on the host, to keep it breathing :wink: