I'm trying to start out with Docker and finding the environment on Windows very frustrating. About half the time I start my laptop Docker Desktop for Windows does not seem to start correctly.
Symptoms:
I've tried restarting both the Docker Engine and the Docker Desktop Service in the services console. That made no difference. The only thing that seems to work is repeatedly restarting the machine until Docker Desktop for Windows runs. That's a less than ideal solution, however. Has anyone a better way of fixing this issue?
By the way, this is running Linux containers, with Kubernetes enabled.
The following Stackoverflow answer, https://stackoverflow.com/a/67091896/216440, suggested using DockerCLI -SwitchDaemon
to fix a similar issue, by switching from using Windows containers to Linux containers, or vice versa.
I tried it but it didn't fix the problem. However, it was the basis for something that did work.
What did work for me was forcing the daemon to use Linux containers, by running the following command in PowerShell:
& 'C:\Program Files\Docker\Docker\DockerCLI.exe' -SwitchLinuxEngine
I was already using Linux containers but, nonetheless, running that command got Docker Desktop for Windows working again.
NOTE: Don't restart your machine after running the command above. It fixes the issue immediately, without the need for a restart. You may encounter the issue again the next time you restart your machine. In that case just re-run the above command to fix the issue.
The equivalent command to force the use of Windows containers may also work, although I haven't tried it:
& 'C:\Program Files\Docker\Docker\DockerCLI.exe' -SwitchWindowsEngine