Home › Docker Tutorial › Resource limits
Resource limits
Stop one container from using everything.
Limit memory with --memory and CPU with --cpus. A container that goes over its memory limit is killed by the kernel (status OOMKilled). Memory is stored in bytes: 256 MB is 268435456.
Example code
docker run -d --memory=256m --cpus=0.5 --name capped nginx:1.27
docker inspect --format '{{.HostConfig.Memory}}' capped