Search code examples
dockercpudocker-compose

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


Solution

  • 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"