How to identify which docker container is consuming 100% CPU
- Open
htop
and pressF6
and selectPERCENT_CPU
. Repeat until you’ve sorted descending by CPU consumption - Now identify the PID (process ID) of the offending process consuming 100% CPU
- In our example, the offending PID is
8599
- Now run this command to find a list of the running docker container by PID:
docker inspect -f '{{.State.Pid}}, {{.Name}}' $(docker ps -q)
- Now identify the line with the PID, e.g.
8599, /wordpress-myblog-btronik_mariadb_1
Now you know which container is consuming 100% CPU.