I have a docker image that hosts a web server and another that runs background tasks. Most of the time the web server is idle, and the background tasks should be allowed to use 100% of the CPUs, but any time the web server needs resources, it should have priority on the CPUs so it can respond quickly.
If everything was running on one linux machine, I could use something like nice -n19 background-task
to run the tasks, and they would allow the web server as much CPU as it needed.
Is there a way to run the whole container at a nice
level? I know I can restrict the amount of CPU time available to each background task with cpu_quota, but this doesn't solve the problem. If the web server wants to use all 4 CPU cores to serve a client it should be allowed. If the web server is not busy, all 4 CPU cores should work on the background task.
If I change the command in the Dockerfile to:
nice -n19 background-task
Will this work between containers? Processes inside containers are all kind of normal processes running on the same kernel, so it seems like it will, but I'm not sure.
This seems like something fairly obvious to do. Am I missing something?
You can run both Linux and Windows programs and executables in Docker containers. The Docker platform runs natively on Linux (on x86-64, ARM and many other CPU architectures) and on Windows (x86-64). Docker Inc. builds products that let you build and run containers on Linux, Windows and macOS.
Before you can use IPv6 in Docker containers or swarm services, you need to enable IPv6 support in the Docker daemon. Afterward, you can choose to use either IPv4 or IPv6 (or both) with any container, service, or network. Note: IPv6 networking is only supported on Docker daemons running on Linux hosts.
Docker is more limited and can run only on Linux, certain Windows servers and IBM mainframes if hosted on bare metal. For example, Docker runs natively only on bare-metal Windows servers running Windows Server 2016 or later.
By default, containers run only as long as their default command executes but a common use case it´s to run them indefinitely for debugging and troubleshooting purposes.
docker
-processes are usual OS processes.
Docker or not is not a concern for process scheduler.
So nice
/renice
works for docker-processes in the same way as for others.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With