4

I see with kubernetes it's possible to set node affinity for certain workloads. I'm wondering if there are any facilities in the various container technologies, such as docker, rocket etc that allow you to pin processes to cores? or if this is even possible in multitenant environments? Perhaps it would imply a bare metal setup?

4

If your system supports SMP (Symmetric multiprocessing) with some combination of multiple physical CPUs, CPU cores, and logical CPUs, you can assign Docker Containers to specific CPU resources.

Example Commands for CPU affinity with Docker Containers

The examples shown here cover the assignment of the mycontainer Docker Container to specific CPU resources when the containers are created with the docker run command. When running commands, you must substitute your Docker Container name and CPU component numbers to suit your environment.

This command will assign the mycontainer Docker Container to the first CPU (CPU0):

# docker run --cpuset 0 /bin/bash mycontainer

Multiple CPUs can be specified. This command will assign the mycontainer Docker Container to CPU 0 and 1:

# docker run --cpuset 0,1 /bin/bash mycontainer

A range of CPUs can be specified. This command will assign the mycontainer Docker Container to CPU 0, 1 and 2:

# docker run --cpuset 0-2 /bin/bash mycontainer

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.