for-mac icon indicating copy to clipboard operation
for-mac copied to clipboard

Docker desktop and engine hang with high CPU usage after computer wakes up from sleep

Open sknop opened this issue 3 years ago • 12 comments

  • [X] I have tried the latest version of Docker Desktop
  • [X] I have tried disabling enabled experimental features
  • [X] I have uploaded Diagnostics
  • Diagnostics ID: 3E0940B1-1183-4352-8168-6C33AC92A988/20221229155906

Expected behaviour

Docker desktop does not deadlock when the computer wakes up from a sleep state, as is common for a laptop.

Actual behaviour

When the laptop wakes up from sleep (moving a mouse, pressing a key), Docker starts consuming 100%-200% CPU and is utterly unresponsive. All docker commands fail, the docker desktop itself is unresponsive and cannot be quit either. The only way I could get the Docker Desktop app to stop is to use Force Quit on my Mac.

Information

This problem appeared after the latest Docker update to the newest version. I ran various diagnostics on docker when it is in that state, and when the diagnostics tool hang, I stopped it via Control-C, which in this instance actually reawakened Docker from its deadlock, so I assume it is a single thread that is deadlocked, and some activity seems to be able to stop that thread, but I have not been able to consistently verify this.

The problem is consistently reproducible: if I force quit the Docker App, restart it again and put the laptop to sleep, Docker will hang when I reawken the laptop again every time. I first did not notice this until I heard the fan spinning and my CPU meter showing consistent load.

  • macOS Version: 12.6.2
  • Intel chip or Apple chip: Intel iCore 7
  • Docker Desktop Version: 4.15.0 (93002)

Output of /Applications/Docker.app/Contents/MacOS/com.docker.diagnose check

Starting diagnostics

[PASS] DD0027: is there available disk space on the host? [PASS] DD0028: is there available VM disk space? [PASS] DD0018: does the host support virtualization? [PASS] DD0001: is the application running? [PASS] DD0017: can a VM be started? [PASS] DD0016: is the LinuxKit VM running? [PASS] DD0011: are the LinuxKit services running? [PASS] DD0004: is the Docker engine running? [PASS] DD0015: are the binary symlinks installed? [PASS] DD0031: does the Docker API work? [PASS] DD0013: is the $PATH ok? [PASS] DD0003: is the Docker CLI working? [PASS] DD0014: are the backend processes running? [PASS] DD0007: is the backend responding? [PASS] DD0008: is the native API responding? [PASS] DD0009: is the vpnkit API responding? [PASS] DD0010: is the Docker API proxy responding? [FAIL] DD0012: is the VM networking working? network checks failed: failed to ping host: exit status 1 [2022-12-30T19:56:55.112506000Z][com.docker.diagnose][I] ipc.NewClient: 35900a4e-diagnose-network -> diagnosticd.sock diagnosticsd [common/pkg/diagkit/gather/diagnose.runIsVMNetworkingOK() [ common/pkg/diagkit/gather/diagnose/network.go:34 +0xd9 [common/pkg/diagkit/gather/diagnose.(*test).GetResult(0x100d5bbc0) [ common/pkg/diagkit/gather/diagnose/test.go:46 +0x43 [common/pkg/diagkit/gather/diagnose.Run.func1(0x100d5bbc0) [ common/pkg/diagkit/gather/diagnose/run.go:17 +0x5a [common/pkg/diagkit/gather/diagnose.walkOnce.func1(0x2?, 0x100d5bbc0) [ common/pkg/diagkit/gather/diagnose/run.go:142 +0x77 [common/pkg/diagkit/gather/diagnose.walkDepthFirst(0x1, 0x100d5bbc0, 0xc0005d3720) [ common/pkg/diagkit/gather/diagnose/run.go:151 +0x87 [common/pkg/diagkit/gather/diagnose.walkDepthFirst(0x0, 0x100d5bd40, 0xc0005d3720) [ common/pkg/diagkit/gather/diagnose/run.go:148 +0x52 [common/pkg/diagkit/gather/diagnose.walkOnce(0x10070dba0?, 0xc00059f888) [ common/pkg/diagkit/gather/diagnose/run.go:137 +0xcc [common/pkg/diagkit/gather/diagnose.Run(0x100d5bd40, 0x600?, {0xc00059fb18, 0x1, 0x1}) [ common/pkg/diagkit/gather/diagnose/run.go:16 +0x1d4 [main.checkCmd({0xc0001b8010?, 0x6?, 0x4?}, {0x0, 0x0}) [ common/cmd/com.docker.diagnose/main.go:133 +0x105 [main.main() [ common/cmd/com.docker.diagnose/main.go:99 +0x2a7 [2022-12-30T19:56:55.113557000Z][com.docker.diagnose][I] (99e8e891) 35900a4e-diagnose-network C->S diagnosticsd POST /check-network-connectivity: {"ips":["192.168.2.82","192.168.2.85"]} [2022-12-30T19:56:55.633103000Z][com.docker.diagnose][W] (99e8e891) 35900a4e-diagnose-network C<-S a967aa94-diagnosticsd POST /check-network-connectivity (519.737145ms): failed to ping host: exit status 1

[SKIP] DD0030: is the image access management authorized? [PASS] DD0019: is the com.docker.vmnetd process responding? [PASS] DD0033: does the host have Internet access? [PASS] DD0018: does the host support virtualization? [PASS] DD0001: is the application running? [PASS] DD0017: can a VM be started? [PASS] DD0016: is the LinuxKit VM running? [PASS] DD0011: are the LinuxKit services running? [PASS] DD0004: is the Docker engine running? [PASS] DD0015: are the binary symlinks installed? [PASS] DD0031: does the Docker API work? [PASS] DD0032: do Docker networks overlap with host IPs?

Please investigate the following 1 issue:

1 : The test: is the VM networking working? Failed with: network checks failed: failed to ping host: exit status 1

VM seems to have a network connectivity issue. Check your host firewall and anti-virus settings in case they are blocking the VM.

(I have hidden network mode - blocking ICMP calls - enabled as enforced by my employer)

Steps to reproduce the behaviour

sknop avatar Dec 30 '22 19:12 sknop

I have seen this several times in the past week or so. Initially with DD 4.15.0 & macOS 12.6.1, but now with DD 4.16.1 & macOS 12.6.2 (updated both in the hopes of making the issue go away). The last time it happened, I had no containers running.

  • macOS Version: 12.6.2
  • Intel chip or Apple chip: Intel iCore 7
  • Docker Desktop Version: 4.16.1 (95567)
  • 'Virtualization framework' is enabled
  • 'VirtioFS' for file sharing

When it occurs, the 'Virtual Machine Service' process consumes anywhere from 75% - 225% CPU (Activity Monitor).

I am able to get out of the state and back to sane using these steps:

  1. 'Restart' from DD menu bar menu.
  2. Wait a few minutes for the CPU usage to drop. Haven't thoroughly tested, but I think the Virtual Machine Service process exits, rather than just consuming less CPU.
  3. 'Quit' from the DD menu bar menu.
  4. Re-launch DD application.

kneden avatar Jan 16 '23 15:01 kneden

I've been experiencing the same issue for the last few weeks, now with MacOS Ventura 13.1, which I upgraded from Monterey with the hope of correcting the problem that was also present before.

  • macOS Version: 13.1
  • Intel chip or Apple chip: Intel iCore 7
  • Docker Desktop Version: 4.16.2 (95914)
  • 'Virtualization framework' is enabled
  • 'VirtioFS' for file sharing

The solution is always the same: quit DD from the menu bar, kill the docker process in the terminal with 'pkill docker', then restart DD and start the container/s that were already running when the computer went to sleep.

raulfragoso avatar Jan 25 '23 15:01 raulfragoso

I've had the same issue and found that it does not happen anymore by disabling the virtualization framework.

So it's worth a try:

  • Go to Docker settings
  • Set the file sharing to FuseFS
  • uncheck the virtualization framework just above
  • apply & restart Docker

In my case, Docker would completely hang after even a few seconds of system sleep. After changing those settings it does not happen anymore!

olance avatar Jan 25 '23 15:01 olance

I've had the same issue and found that it does not happen anymore by disabling the virtualization framework.

So it's worth a try:

  • Go to Docker settings
  • Set the file sharing to FuseFS
  • uncheck the virtualization framework just above
  • apply & restart Docker

In my case, Docker would completely hang after even a few seconds of system sleep. After changing those settings it does not happen anymore!

That fixed the issue! After changing the file sharing to gRPC FUSE and disabling the Virtualization framework, I can now put my Mac to sleep and the container will be properly running when it's awake again. Thank you!

raulfragoso avatar Jan 25 '23 17:01 raulfragoso

That fixed the issue! After changing the file sharing to gRPC FUSE and disabling the Virtualization framework, I can now put my Mac to sleep and the container will be properly running when it's awake again. Thank you!

Great! 😁 You're very welcome, this was driving me crazy as well!

olance avatar Jan 25 '23 18:01 olance

i was having this issue with Docker version 20.10.23, build 7155243 running on OSX Ventura. 13.2.1

sallespro avatar Mar 10 '23 12:03 sallespro

Can conform, had this issue on macOS Monterey on an Intel Mac after a recent Docker upgrade (to 20.10.23, commit 7155243). Following the workaround described in this issue (disabling virtualisation framework) works.

rkettelerij avatar Mar 31 '23 06:03 rkettelerij

Tried the workaround with gFUSE and by disabling the virtualization framework... no improvement, it's even worst.

Now the process com.docker.hyperkit has the high CPU usage :( . Hope to find a solution one day... it worked at a time but don't remember the perfect combinaison.

sneko avatar Apr 21 '23 07:04 sneko

Radical choice adopted! I had issues with Docker having unstable performance on Windows years ago, and on MacOS too randomly since then. I'm done 😄

Just decided to go with Podman (already used with success on some servers to benefit from the rootless feature):

  1. Install "Podman Desktop"
  2. Init & Start
  3. Install podman-compose
  4. Set aliases to keep all your commands and tools:
alias docker=podman
alias docker-compose=podman-compose

Can't say right now it will be fully compatible in all situations, but at least I have a decent CPU usage (which is required to have a smooth development experience 😉 ).

sneko avatar Apr 21 '23 08:04 sneko

My issue is when I build my container using docker-compose, tasks like com.docker.b, docker-scout and com.apple.Vi keep running taking all the cpu, when I restart docker, it fixes the issue. By setting file sharing to gRPC FUSE is not helping the issue remains, what could it be?

jorgesisco avatar Dec 17 '23 08:12 jorgesisco

Same here.
Macbook M1 Macos 13.4.1 (22F82) Docker Desktop 4.26.1 (131620) Kubernetes is on Docker's dashboard shows NaN% / 200% (2 cores available) Activity monitors shows constant 200-230% CPU usage by Docker.

Docker restart helps till the next night morning. So I restart it on a daily basics.

tpoxa avatar Jan 06 '24 12:01 tpoxa

I have the same issue. Docker restart is the only solution.

InvisibleProgrammer avatar Feb 08 '24 09:02 InvisibleProgrammer