Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker Compose shared CPUs

In Docker Compose is there a way to create containers with their own CPU? I don't want them to share CPUs I´ve allocated to them.

Suppose I give to Docker access to 3 CPUs: I want each of my three containers to have its own CPU.

Is it possible?

Thanks

like image 247
Naramsim Avatar asked Jun 01 '26 22:06

Naramsim


1 Answers

Limit the specific CPUs or cores a container can use. A comma-separated list or hyphen-separated range of CPUs a container can use, if you have more than one CPU. The first CPU is numbered 0. A valid value might be 0-3 (to use the first, second, third, and fourth CPU) or 1,3 (to use the second and fourth CPU).

docker run --cpuset-cpus="0" [...]

In docker-compose:

services:
  service:
    cpuset: "0"
like image 120
Mathias Dewelde Avatar answered Jun 05 '26 02:06

Mathias Dewelde



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!