I have an Ubuntu container with, among other things limits.cpu: “1”. Normally this has the intended effect: logging into the container shows one CPU at any given time. However, I’ve also observed multiple times that immediately after launching, the container will momentarily display all (40) host CPUs. I’ve seen this manifest multiple ways, including:
- Immediately opening a shell and running htop inside the container
- Inspecting log output from the apps inside the container that start immediately
The limit eventually kicks in, but seemingly not always before apps have started up and “assumed” there to be 40 cores available - which can be problematic as it causes them to way over-provision themselves for the resources that are actually available.
Is this expected behavior?
# Base information - Distribution: Ubuntu - Distribution version: 20.04.2 LTS (Focal Fossa) - Kernel version: Linux fusion 5.8.0-63-generic #71~20.04.1-Ubuntu SMP Thu Jul 15 17:46:08 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux - LXC version: 4.16 - LXD version: 4.16 - Snap revision: 21039