Hands-on task
The limit Docker sets
The cache service keeps warmed-up data in memory: every restart means half an hour of cold cache and a slow site. It's run with a 128 MiB memory limit, and today it turned out that's not enough: it needs 384 MiB, and without a restart.
- Start a container
cachein the background from thebusybox:1.36image with a memory limit of128m; instead of a real cache, letsleeprun inside for an hour. - Find the container's cgroup on the server and look at its
memory.max— that's how the kernel sees the--memoryflag. - Raise the running container's limit to
384mwithout recreating or restarting it, and make surememory.maxin the same group has changed.
The cache needs no swap: let the combined memory-and-swap limit equal the new memory limit.
- cgroups
- cgroup v2
- docker
- /proc