So in my current app setting a certain process running inside a container runs another process. I need to set the nice value of the new process to be higher.
When ran on the OS I could just do
nice -n19 second_task
. How does this work in the context of the docker container?
2
Answers
First of all one container should run only one process that is its single responsibility, containers should not be treated like VMs but like boundaries (container:)) for your services.
nice
should work the same as it is working on the host because container processes are eventually processes on the host, so you could donice
in your Dockerfile CMD parameter. But this is something that you should control with a container orchestrator that is kubernetes for today de facto (there are other ones like docker swarm and nomad)It works exactly the same way. When you’re inside docker OS, you can just
nice -n19 second_task
.Exactly the same restrictions apply as outside docker OS, so
nice
executable has to exists inside docker OS to be run, the same way thenice
executable has to exist for you to runnice
on your host OS. And user has to have appropriate limits (seeman limits.conf
) or be root.