skip to Main Content

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


  1. 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 do nice 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)

    Login or Signup to reply.
  2. When ran on the OS I could just do nice -n19 second_task. How does this work in the context of the docker container?

    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 the nice executable has to exist for you to run nice on your host OS. And user has to have appropriate limits (see man limits.conf) or be root.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search