I'm running my container with
docker run --rm -it --cpus=1 --memory "8G" -v "$pwd":"/code/" 'algolab' bash 
This means according to the docs that the container will only use one cpu core.
--cpus=0.000Number of CPUs.
Number is a fractional number. 0.000 means no limit.
But when I run nproc inside the container, it tells me it sees 8 cores - the same number as on my host.
This answer supports that claim. But it also mentions --cpuset-cpus="0-2". When I use that, in addition to --cpus=1, I get the result 3 from nproc.
Why is docker ignoring --cpus=1?
And how do I make it stop ignoring it?
For now, I can use --cpuset-cpus="0", but I don't understand why that's necessary.
$ docker --version
Docker version 19.03.6, build 369ce74a3c
The --cpus option sets a quota on the CPU usage - this does not restrict which CPUs can be used nor how many at a time; this restricts the total slice of time they can be running on your CPU. So if you pass --cpus 1 on a machine with 8 cores, the container will be limited to running on 1/8th of your CPU time. This is covered on a different section of the docs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With