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

Docker refuses to shut down

Open IainMcCracken opened this issue 1 year ago • 22 comments

Description

When I select "Quit Docker Desktop" from the menu at the bottom of the Docker Destop window, it shows the "Turning off the Docker Engine..." page for a very long time, then returns to the regular list of containers screen.

At this point, it is dead. Containers do not open. The Desktop app cannot access the contents of volumes. Nothing works.

Windows Task Manager says that the docker desktop and docker backend tasks are still running.

The only way to get Docker back up and running again is to force all tasks with "docker" in the name to exit. Or reboot the machine.

Reproduce

  1. Run Docker Desktop from the Start menu, or by double-clicking the icon on the desktop.
  2. Select "Quit Docker Desktop" from the menu at the bottom of the window.

Expected behavior

"Quit Docker Desktop" should:

  1. Stop the Docker Engine
  2. Exit Docker Desktop

docker version

Client:
 Version:           27.4.0
 API version:       1.47
 Go version:        go1.22.10
 Git commit:        bde2b89
 Built:             Sat Dec  7 10:40:21 2024
 OS/Arch:           windows/amd64
 Context:           desktop-linux

Server: Docker Desktop 4.37.0 (178034)
 Engine:
  Version:          27.4.0
  API version:      1.47 (minimum version 1.24)
  Go version:       go1.22.10
  Git commit:       92a8393
  Built:            Sat Dec  7 10:38:57 2024
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.7.21
  GitCommit:        472731909fa34bd7bc9c087e4c27943f9835f111
 runc:
  Version:          1.1.13
  GitCommit:        v1.1.13-0-g58aa920
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

docker info

Client:
 Version:    27.4.0
 Context:    desktop-linux
 Debug Mode: false
 Plugins:
  ai: Ask Gordon - Docker Agent (Docker Inc.)
    Version:  v0.5.1
    Path:     C:\Program Files\Docker\cli-plugins\docker-ai.exe
  buildx: Docker Buildx (Docker Inc.)
    Version:  v0.19.2-desktop.1
    Path:     C:\Program Files\Docker\cli-plugins\docker-buildx.exe
  compose: Docker Compose (Docker Inc.)
    Version:  v2.31.0-desktop.2
    Path:     C:\Program Files\Docker\cli-plugins\docker-compose.exe
  debug: Get a shell into any image or container (Docker Inc.)
    Version:  0.0.37
    Path:     C:\Program Files\Docker\cli-plugins\docker-debug.exe
  desktop: Docker Desktop commands (Beta) (Docker Inc.)
    Version:  v0.1.0
    Path:     C:\Program Files\Docker\cli-plugins\docker-desktop.exe
  dev: Docker Dev Environments (Docker Inc.)
    Version:  v0.1.2
    Path:     C:\Program Files\Docker\cli-plugins\docker-dev.exe
  extension: Manages Docker extensions (Docker Inc.)
    Version:  v0.2.27
    Path:     C:\Program Files\Docker\cli-plugins\docker-extension.exe
  feedback: Provide feedback, right in your terminal! (Docker Inc.)
    Version:  v1.0.5
    Path:     C:\Program Files\Docker\cli-plugins\docker-feedback.exe
  init: Creates Docker-related starter files for your project (Docker Inc.)
    Version:  v1.4.0
    Path:     C:\Program Files\Docker\cli-plugins\docker-init.exe
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
    Version:  0.6.0
    Path:     C:\Program Files\Docker\cli-plugins\docker-sbom.exe
  scout: Docker Scout (Docker Inc.)
    Version:  v1.15.1
    Path:     C:\Program Files\Docker\cli-plugins\docker-scout.exe

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Server Version: 27.4.0
 Storage Driver: overlayfs
  driver-type: io.containerd.snapshotter.v1
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Cgroup Version: 1
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local splunk syslog
 CDI spec directories:
  /etc/cdi
  /var/run/cdi
 Swarm: inactive
 Runtimes: io.containerd.runc.v2 nvidia runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 472731909fa34bd7bc9c087e4c27943f9835f111
 runc version: v1.1.13-0-g58aa920
 init version: de40ad0
 Security Options:
  seccomp
   Profile: unconfined
 Kernel Version: 5.15.167.4-microsoft-standard-WSL2
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 8
 Total Memory: 5.684GiB
 Name: docker-desktop
 ID: 1eb8afd9-cfef-4a4a-aaa2-2342b322d447
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 HTTP Proxy: http.docker.internal:3128
 HTTPS Proxy: http.docker.internal:3128
 No Proxy: hubproxy.docker.internal
 Labels:
  com.docker.desktop.address=npipe://\\.\pipe\docker_cli
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5555
  127.0.0.0/8
 Live Restore Enabled: false

Diagnostics ID

1895F3C5-FBAB-4EF2-B6D7-BB9852659B2D/20241214191646

Additional Info

I'm going go back to 4.36 which seems to work.

IainMcCracken avatar Dec 14 '24 19:12 IainMcCracken

In case it helps Docker, this is where we discussed it originally: https://forums.docker.com/t/new-bug-4-37-0-docker-desktop-refuses-to-shut-down/145478

We could not reproduce the issue with DD v4.37 and so far the only difference we saw is the hardware. Also quoting an error shared by @IainMcCracken on the forum:

I’m looking at the log files (AppData/Local/Docler/log/vm) and in 01-docker.log I see a slew of errors about device or resource busy, failed to remove cgroup.

But I checked now, and I have those error messages too without having any problem with quitting Docker Desktop

rimelek avatar Dec 14 '24 21:12 rimelek

Thanks, rimelek, for adding that info.

I am at a loss as to why 4.37 works just fine on my desktop, and not on my laptop, while 4.36 is fine on both machines.

IainMcCracken avatar Dec 14 '24 21:12 IainMcCracken

Update...

Version 4.37.1 just installed itself on my laptop and it shuts down just fine.

So, there was something about my laptop and 4.37.0 that was problematic. No idea what, though.

IainMcCracken avatar Dec 19 '24 01:12 IainMcCracken

I have been experiencing this issue on my work desktop since December. Docker Desktop takes a couple of minutes to shut down because it appears to be reading docker_data.vhdx in its entirety. That file has 154 GB on my disk, which is doing about two gigabytes per second of sequential reads.

I am running Docker Desktop 4.37.1 on Windows 11 23H2.

(EDIT) Resolved my particular problem by running

docker system prune -a

The next Docker Desktop shutdown took a few minutes but shrunk the file to 12 GB. So I think the problem is that Docker Desktop is trying to shrink the file every time; it takes a long time and fails to make it any smaller. New/fresh installations won't have the issue.

tomaskarban avatar Jan 17 '25 21:01 tomaskarban

I just experienced the same issue on Win10, running Docker Desktop 4.37.1 --- found your other post, which led me here. Had to open task manager to kill the app finally.

iq-nkraft avatar Jan 22 '25 17:01 iq-nkraft

I also have the same problem closing docker desktop! I am on version 4.37.1 with w10 pro and hyper-v activated but with docker in wsl2. I don't have an image or a container! I have the same installation on a 2nd PC which works without problem (other hardware) everything worked 2 months ago, I changed my 1060 graphics card -> RTX 4060 I don't know if this is the cause because I didn't test it right after but now it's gone.

To create the problem:

  • Launch of docker desktop
  • Nothing
  • Docker shutdown

(In addition to the problem I cannot launch docker desktop with ubuntu 20.04) but it works under Windows

I tried without success:

  • Reinstall docker and ubuntu 5 times, removing everything that I think is related to docker desktop.

  • Disable and re-enable hyper-v

  • docker system plum -a

  • And many other tests (4 days of work)

I despair!

LMCreation avatar Jan 29 '25 14:01 LMCreation

just after sending my message I found an interesting manipulation:

  • Docker Desktop: Launch as administrator
  • In powershell as admin: docker system prune -a
  • Close Docker Desktop => it works
  • Relaunch the Docker desktop
  • Test on ubuntu-20.04: docker -v => it works !!
  • Restart Windows + re-test => it works !

For search engines, for people who have the same problem my errors were:

  • Unable to stop docker desktop (main problem to finish)
  • No wsl2 in ubutu
  • Unable to access the specified distribution mount service: stat /run/guest-services/distro-services/ubuntu-20.04.sock: No such file or directory
  • running wsl-bootstrap: exit status 1
  • unable to integrate docker into ubuntu
  • The command 'docker' could not be found in this WSL 2 distro

LMCreation avatar Jan 29 '25 15:01 LMCreation

Now I have this since version 4.40.0 in 4.39 that was not a case

ThePlenkov avatar Apr 04 '25 13:04 ThePlenkov

Having same issue. Whenever I start my computer with 4.40, it hangs and refuses to start forever. Unable to stop it either. When I shutdown/reboot my Windows, it hangs forever. I have to hard power it off, because the shutdown/reboot never finishes. After that it works, but next reboot it doesn't. Not sure exactly whats causing it, also if I don't start it immedately after reboot it will hang too when st arted some time later.

The recent few versions of Docker have been catastophic in quality. Is there no QA team responsobilbe for testing this before releasing? I never had issues with docker until about 6-12 months ago.

Especially the last 4 versions have been more than awful. Twice I wasted multiple hours to get it working again, because after an update, it wouldn't start (but at least I got an error message and had to look for hours for an solution. First I had to shutdown WSL, the second time I lost my complete data volume INCLUDING all volumes, which took me hours to restore and now I have to reboot multiple times until it gets running.

Please, stop adding new useless features and paywall! Make sure its stable and runs, we depend on it working for our jobs. Waisting 2 days is really expensive and a big loss.

TsengSR avatar Apr 22 '25 08:04 TsengSR

For me the issue is just with the desktop ui component. when it goes to (completely useless, does literally nothing) eco-sleep mode it will refuse to quit until you start an image, at which point it quits abruptly - like go to press the play button to start a container, but you had previously asked it to quit so it quits at that point.

Have had the bug on/off for months. I think it happens when you have stopped containers for a while(like hours/days). it's always very annoying.

very annoying "feature" and also if no containers are running what is the app even supposedly putting to sleep? if the desktop ui app isn't receiving any events what code is there to put into sleep that would be running and using cpu. Pls don't add "helpful features" that just break the thing.

lassikin avatar May 24 '25 12:05 lassikin

I had the same issue with Docker Desktop 4.42.0 on a Windows 10 Host with WSL 2, after pruning unused containers and images. Docker Desktop would take approx. 10 minutes "Turning off the Docker Engine". Then I did a docker system prune -a and restarted my machine which freed about 70GB of disk space. Now when I quit Docker Desktop it shuts down in seconds. Problem solved for me.

MKupi avatar Jun 24 '25 06:06 MKupi

When I tried docker system prune -a, I got

WARNING! This will remove:
  - all stopped containers
  - all networks not used by at least one container
  - all images without at least one container associated to them
  - all build cache

Are you sure you want to continue? [y/N] y
error during connect: Head "http://%2F%2F.%2Fpipe%2FdockerDesktopLinuxEngine/_ping": open //./pipe/dockerDesktopLinuxEngine: The system cannot find the file specified.

danon avatar Jul 02 '25 07:07 danon

I have to almost always "wsl --shutdown".

miikkamakela-into avatar Jan 08 '26 05:01 miikkamakela-into

I have the same issue on my work Lenovo laptop with 16 GB of RAM. I'm on Docker v4.55.0 with WSL2 backend and Windows 11 24H2 (OS Build 26100.6584)

Image

Tried docker system prune -a also as suggested, reclaimed about 11 gigs, didn't help at all.

dima2306 avatar Jan 09 '26 06:01 dima2306

only one thing ever helped me get out of this - full wipe of all volumes and images in registry (not just dangling, actually full wipe). I suspect beyond particular size of registry (100 GB+) the docker gets hit by I/O limits because registry on windows is single giant blob

dimon222 avatar Jan 09 '26 14:01 dimon222

I actually did reset WSL2 in the docker settings which wiped all volumes and containers. Before any action my docker size was 40 gigs (which isn't a big number) but still, docker was refusing to close. I let it to power off the engine for about 2 hours but it's hanging. I just deleted docker desktop.

dima2306 avatar Jan 10 '26 08:01 dima2306

Same issue, Docker Engine is stopping... forever.

Version 4.55, there is an update to 4.57 available but I can't install it, because to install it first needs to stop.

danielblnc avatar Jan 25 '26 02:01 danielblnc

Seems the issue has persisted to 4.76.0, docker just hangs on stopping forever if i ask it to restart or quit

EddiebleDoormouse avatar Jul 02 '26 15:07 EddiebleDoormouse

Seems the issue has persisted to 4.76.0, docker just hangs on stopping forever if i ask it to restart or quit

Yea this shit is annoying. I Skip most updates instead of updating every version which reaks my shit. And when I upgrade I always make a backup for the vhdx files before doing so, cause the only thing that helps often is uninstall and reinstall, which deletes your vhdx files and with it all your containers, configurations etc.

Docker became useless at begin of 2026 with the AI slop quality its developed these days. No one quests it, just updates every week which keep breaking more than they fix.

TsengSR avatar Jul 02 '26 21:07 TsengSR

I am having exactly the same issue, and because I have to run wsl --shutdown, it seems the settings update don't take, and I can't get wsl2 in my distro.

splatwebsol avatar Jul 21 '26 17:07 splatwebsol