Docker high CPU consuption

Morning everyone.

I’m trying to run two containers with just a pretty simple websites.

I’ve notice that when those two are up, my desktop top 100% cpu usage and go dead slow. When just one are up, CPU usage go high.

After some lookup, found some options to restrain cpu usage, but they seem effectiveness

They are being started with:

’ sudo docker run -it -p 9876:80 --cpu-period=1000 --cpu-quota=20000 --memory=512m 28823b97257a /bin/bash &’

to illustrate:

(can’t upload two images, only one)

anyone may give a heads up?

Where did you take the screenshot? Docker daemon in Docker desktop is running in a virtual machine, so you would not see the daemon unless you execute the command in the “docker-desktop” WSL ditribution. Did you do that?

Your screenshot also shows that the docker run command uses the resources, not the process es in the container. That is why the resource limits don’t help as those are for the containers, not the client.

And if you are really using Docker Desktop, I don’t think you need sudo. I never use it with Docker Desktop and if you have another docker daemon on the host, not just in the virtual machine, when you are using sudo, you are probbaly starting the containers outside Docker Desktop.

  1. I’ve just open a terminal, execute htop and took the screenshot;

    1.1) Not sure about what you asked. Not using WSL, just my workstation, with docker installed via apt;

  2. Limits in parameters are apply to container, not the client, right. Than, why to use them and when they kick in?

    2.1) How may i control client cpu usage? I just want to make my websites available on local network to my teammates test, but when i do, my machine goes useless;

  3. Now, not that sure if i’m using docker desktop. Basically, i use sudo nothing works without it.

Sorry, I posted in a hurry and I misunderstood your first post. I saw “desktop” and I thought you were using Docker Desktop and I don’t know why I assumed Windows… Now I know you are not using any Docker desktop

If the client command uses that much resources, that could be a bug. I will share a template text for debugging. Please, answer the questions and we can continue debugging..

We usually need the following information to understand the issue:

  1. What platform are you using? Windows, Linux or macOS? Which version of the operating systems? In case of Linux, which distribution?

  2. How did you install Docker? Sharing the platform almost answers it, but only almost. Direct links to the followed guide can be useful.

  3. On debian based Linux, the following commands can give us some idea and recognize incorrectly installed Docker:

    docker info
    docker version
    

    Review the output before sharing and remove confidential data if any appears (public IP for example)

    dpkg -l 'docker*' | grep '^ii'
    snap list docker
    

    When you share the outputs, always format your posts according to the following guide: How to format your forum posts

  1. I’m using a Debian 12;

  2. Not sure how exactly i’ve install docker, but pretty sure that was with ‘sudo apt install docker’ or ‘docker*’;

$ docker info
Client:
 Context:    default
 Debug Mode: false

$ docker version
Client:
 Version:           20.10.24+dfsg1
 API version:       1.41
 Go version:        go1.19.8
 Git commit:        297e128
 Built:             Fri Apr 18 15:01:23 2025
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

$ dpkg -l 'docker*' | grep '^ii'
ii  docker                    1.5-2                       all          transitional package
ii  docker.io                 20.10.24+dfsg1-1+deb12u1+b1 amd64        Linux container runtime
$ snap list docker
error: no matching snaps installed

I appreciate your attention

That seems to be the case, but the docker package is actually not Docker, the container engine. I guess you realized it and installed docker.io, but that is not the officially supported version by Docker Inc. And it will install an old version mainained by the maintainers of Debian, not Docker Inc.

Here is the official installation guide: https://docs.docker.com/engine/install/debian

If you can reproduce the issue with that too, we can continue figuring out if it is a Docker CE bug or anything else. If it is a bug in docker.io, that will not be fixed, unless the Debian maintainers make a patch for their package.