Dockerd 100% CPU Usage
Cause
One potential cause of this issue is Docker's log files becoming corrupt, possibly due to your filesystem filling up or an unexpected power outage.
Fix
- Use the following script to find any corrupt log files in your Docker containers:
sudo find /var/lib/docker/containers/ -name *-json.log -exec bash -c 'jq '.' {} > /dev/null 2>&1 || echo "Corrupted Logfile: {}"' \;
- You can safely delete the listed log files manually, or by using the following script:
sudo find /var/lib/docker/containers/ -name *-json.log -exec bash -c 'jq '.' {} > /dev/null 2>&1 || sudo rm {}' \;
Explanation
find /var/lib/docker/containers -name \*-json.log
: searches for all files that end with -json.log within /var/lib/docker/containers and forwards them to jq to parse them.jq '.' {}
: runs the output offind
through the jq JSON parser, returns 0 if parsing succeeds, or the file's name as {} if it doesn't.||
: OR operator, the code after this operator will only execute if >0 was returned by jq.