简体   繁体   English

Docker 在 Windows 10 中启动时桌面崩溃

[英]Docker desktop crash on start up in Windows 10

I installed docker desktop on Windows 10 through 'Docker Desktop Installer'.我通过“Docker Desktop Installer”在 Windows 10 上安装了 docker 桌面。

After installation I logged off and logged in. It crashes on start up after some time stating the message as below安装后我注销并登录。一段时间后它在启动时崩溃并显示如下消息

Docker.Core.Backend.BackendDestroyException:
One or more errors occurred.
   at Docker.Core.Pipe.NamedPipeClient.<TrySendAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at Docker.Core.Pipe.NamedPipeClient.Send(String action, Object[] parameters)
   at Docker.Actions.DoStart(SynchronizationContext syncCtx, Boolean showWelcomeWindow, Boolean withNotifications)
   at Docker.Actions.<>c__DisplayClass26_0.<StartAsync>b__0()
   at Docker.ApiServices.TaskQueuing.TaskQueue.<>c__DisplayClass18_0.<.ctor>b__1()

  System.AggregateException:
  One or more errors occurred.
     at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
     at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
     at Docker.Backend.LifecycleClient.DockerStart()
     at Docker.Backend.ContainerEngine.Linux.DoStart(Settings settings, String daemonOptions, Credential credential)
     at Docker.Backend.ContainerEngine.Linux.Start(Settings settings, String daemonOptions, Credential credential)

     Docker.Core.HttpBadResponseException:
     unable to fetch daemon.json: Get http://unix/engine/daemon.json: net/http: request canceled (Client.Timeout exceeded while awaiting headers)
        at Docker.Backend.HttpClientExtensions.<ParseResponseBodyAsJsonAsync>d__2`1.MoveNext()
     --- End of stack trace from previous location where exception was thrown ---
        at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
        at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
        at Docker.Backend.HttpClientExtensions.<GetJsonAsync>d__0`1.MoveNext()

I uninstalled, re-started my PC and installed by selecting 'Windows Container'.我卸载、重新启动我的电脑并通过选择“Windows 容器”进行安装。 Then after the restart checked on running docker. It started successfully.然后在重新启动后检查运行 docker。它启动成功。 But when I switch to Linux containers it again fails with the same error message above.但是当我切换到 Linux 容器时,它再次失败并显示与上面相同的错误消息。

The main goal to fix this is:解决此问题的主要目标是:

  1. Press windows "start" button按windows“开始”按钮
  2. Enter by keyboard services + enter通过键盘services输入+回车
  3. Find two of them : "Hyper-V Virtual Machine Management" and "Hyper-V Host Computer Service"找到其中两个:“Hyper-V 虚拟机管理”和“Hyper-V 主机服务”
  4. (on each service)click mouse right-button, select "properties" and change in opened window "startup type" to "manual", then "ok" button. (在每个服务上)单击鼠标右键,选择“属性”并在打开的窗口中将“启动类型”更改为“手动”,然后单击“确定”按钮。
  5. Click again on each mouse right-button and select start再次单击每个鼠标右键并选择开始
  6. Press windows "start" button, enter "hyper-v", it will show you hyper manager, open it按windows“开始”按钮,输入“hyper-v”,它会显示你的超级管理器,打开它
  7. In hyper-v manager select "connect to server", from pop-up select "local computer"在 hyper-v 管理器中选择“连接到服务器”,从弹出窗口中选择“本地计算机”
  8. Run your desktop docker it is probably working now with no crashes and exceptions.运行您的桌面 docker,它现在可能正在运行,没有崩溃和异常。
  1. Click on the Start button点击开始按钮
  2. Then type services然后输入服务
  3. Search for Docker Desktop Services .搜索Docker 桌面服务
  4. Click on that点击那个
  5. On the top left click on stop service在左上角点击停止服务
  6. Then click on start service .然后点击启动服务

now open windows powershell as administrator现在以管理员身份打开 windows powershell
type docker输入docker
this will show you the list of commands这将向您显示命令列表
after that type docker images之后输入docker images
this will show you the following error这将向您显示以下错误

error during connect: This error may indicate that the docker daemon is not running.连接过程中的错误:此错误可能表明 docker 守护程序未运行。

After that run this command之后运行这个命令

& 'C:\Program Files\Docker\Docker\DockerCli.exe' -SwitchDaemon

and then run the following command然后运行以下命令

docker images

This will solve your problems这将解决您的问题

What helps is already given in the other answers, i just try to be more specific and try to avoid some traps by using Environment-Variables in the paths and append some details and reasoning for the core problem:其他答案中已经给出了帮助,我只是尝试更具体,并尝试通过在路径中使用环境变量来避免一些陷阱,并为核心问题附加一些细节和推理:

First of all, make sure the "Docker Desktop Service" is running, which should be the case once you logged out and in again directly after install or rebooted the system.首先,确保“Docker 桌面服务”正在运行,一旦您注销并在安装或重新启动系统后直接再次登录,应该就是这种情况。 To check the status of services do either click/press/touch the Start-Button/Windows-Key to initiate the integrated Desktop-Search and type:要检查服务的状态,请单击/按下/触摸开始按钮/Windows 键以启动集成的桌面搜索并键入:

services

or type或输入

services.msc

in either the desktop-search as stated before, or open the Run-dialog by pressing and holding down the "Windows-Key" and the "R"-key right after it as well, then release the keys.在前面所述的桌面搜索中,或者通过同时按住“Windows键”和“R”键打开运行对话框,然后释放这些键。 In the "Run-Dialog" type在“运行对话框”类型中

services.msc

Use the command-line-interface (CLI)-tool "DockerCli.exe" with the attribute/option "SwitchDaemon".使用带有属性/选项“SwitchDaemon”的命令行界面 (CLI) 工具“DockerCli.exe”。 For this you need to open a command-line, either PowerShell or CommandShell, you do this by either click/press/touch the Start-Button/Windows-Key to initiate the integrated Desktop-Search and type:为此,您需要打开命令行,PowerShell 或 CommandShell,您可以通过单击/按下/触摸开始按钮/Windows 键来启动集成的桌面搜索并键入:

cmd

for the CommandShell, or for the PowerShell:对于 CommandShell 或 PowerShell:

powershell

or you type " cmd.exe " or " powershell.exe " in either the Desktop-Search as stated before, or you或者您如前所述在桌面搜索中键入“ cmd.exe ”或“ powershell.exe ”,或者您

open the Run-dialog by pressing and holding down the "Windows-Key" and the "R-Key" right after it as well, then release the keys.通过同时按住“Windows-Key”和“R-Key”打开运行对话框,然后松开这些键。 In the "Run-Dialog" type " cmd.exe " or " powershell.exe ".在“运行对话框”中键入“ cmd.exe ”或“ powershell.exe ”。

To actually switch the Docker-Service operation-mode use the following:要实际切换 Docker-Service 操作模式,请使用以下命令:

If you are in the Command-Shell/cmd.exe type:如果您在 Command-Shell/cmd.exe 中,请键入:

cmd -C "%ProgramFiles%\Docker\Docker\DockerCli.exe -SwitchDaemon"

Or if you are in PowerShell type:或者,如果您使用 PowerShell 类型:

& "Env:ProgramFiles\Docker\Docker\DockerCli.exe -SwitchDaemon"

If all that is too complex for you and you want to try a "fire&forget"-approach - relying on the assumption that the Docker-Desktop-Service is indeed running, because you either logged out and back in after install or you already rebooted your system, you may use the Run-Dialog (to open via Win+R) and paste the following line:如果这一切对您来说太复杂并且您想尝试“fire&forget”- 方法 - 依赖于 Docker-Desktop-Service 确实正在运行的假设,因为您要么在安装后注销并重新登录,要么您已经重新启动了您的系统,您可以使用 Run-Dialog(通过 Win+R 打开)并粘贴以下行:

powershell.exe & "$Env:ProgramFiles/Docker/Docker/DockerCli.exe -SwitchDaemon"

This will work because it explicitly executes the PowerShell (which is part of Windows 10 and Docker Desktop only runs on Windows 10) and passes to it the command DockerCli.exe -SwitchDaemon.The path is determined via the System-Environment-Variable ProgramFiles which will resolve to your System-Root and Program-Files directory (in most cases "C:\Program Files", but can also be on a manually set drive-letter, eg "B:" (which is often used on embedded systems to prevent automatic creation of swap-files), so on "B:\Program Files" in that case.这将起作用,因为它显式执行 PowerShell(它是 Windows 10 的一部分,Docker Desktop 仅在 Windows 10 上运行)并将命令 DockerCli.exe -SwitchDaemon 传递给它。路径是通过 System-Environment-Variable ProgramFiles 确定的将解析到您的 System-Root 和 Program-Files 目录(在大多数情况下为“C:\Program Files”,但也可以在手动设置的驱动器号上,例如“B:”(通常在嵌入式系统上用于防止自动创建交换文件),在这种情况下以“B:\ Program Files”为例。

It relies on the standard install-path of Docker Desktop on Windows 10 systems, if you changed it you have to adjust the path accordingly.它依赖于 Windows 10 系统上 Docker Desktop 的标准安装路径,如果您更改它,则必须相应地调整路径。 You will have no feedback.您将没有任何反馈。 Just start "Docker Desktop" from your Start-Menu after you pasted and executed the command from the Run-Dialog.粘贴并执行 Run-Dialog 中的命令后,只需从 Start-Menu 启动“Docker Desktop”。

The path in all examples is set in quotes ("") to guarantee that it can be executed.所有示例中的路径都设置在引号(“”)中,以保证可以执行。 This would be a necessity as well if you for example want to prepare a Shortcut on the Desktop for first use after deployment, eg titled "Run this once (if Docker Desktop fails to start)".这也是必要的,例如,如果您想在桌面上准备一个快捷方式以供部署后首次使用,例如标题为“运行一次(如果 Docker 桌面无法启动)”。 This way you can make it part of an image with Docker preinstalled.通过这种方式,您可以使其成为预安装 Docker 的映像的一部分。

Be aware that the main problem is that Docker uses WSL2 to provide its Linux-based containers (on Windows 10 Home exclusively) and that to run Windows-Containers Hyper-V needs to be enabled, sadly the latter contradicts with WSL2 on Windows 10 Desktop operating systems.请注意,主要问题是 Docker 使用 WSL2 来提供其基于 Linux 的容器(仅在 Windows 10 Home 上),并且需要启用 Hyper-V 来运行 Windows-Containers,遗憾的是后者与 Windows 10 桌面上的 WSL2 相矛盾操作系统。 You can enable Hyper-V afterwards, together with Virtual-Machine-Services and Windows-Containers via Windows 10 Features, but it is not guaranteed it will work toegther with WSL2.之后,您可以通过 Windows 10 功能启用 Hyper-V 以及虚拟机服务和 Windows 容器,但不能保证它可以与 WSL2 一起使用。

The solution for me was to enable virtualization for my CPU in my computer's BIOS.我的解决方案是在我的计算机的 BIOS 中为我​​的 CPU 启用虚拟化。 Docker relies on virtualization to make containers work. Docker 依靠虚拟化来使容器工作。 For me, when it was disabled, Docker Desktop kept crashing and restarting and unhelpfully giving me very little information.对我来说,当它被禁用时,Docker Desktop 不断崩溃并重新启动,并且毫无帮助地给了我很少的信息。

Here's a helpful page with some details on how to enable virtualization: https://bce.berkeley.edu/enabling-virtualization-in-your-pc-bios.html这是一个有用的页面,其中包含有关如何启用虚拟化的一些详细信息: https ://bce.berkeley.edu/enabling-virtualization-in-your-pc-bios.html

The short instructions are:简短的说明是:

  1. Reboot your computer.重新启动计算机。
  2. Press DEL or F2 or whatever it is for your computer to get into the BIOS.按 DEL 或 F2 或任何您的计算机进入 BIOS 的键。
  3. Look for CPU settings, then find something called VT-x, AMD-V, SVM, or Vanderpool.查找 CPU 设置,然后找到称为 VT-x、AMD-V、SVM 或 Vanderpool 的东西。 Enable it.启用它。
  4. Save settings and restart your computer.保存设置并重新启动计算机。

You should be open Hyper-V section.Docker doesn't work without Hyper-V.您应该打开 Hyper-V 部分。没有 Hyper-V,Docker 将无法工作。

How to open Hyper-V section:如何打开 Hyper-V 部分:

  1. Right click on the Windows button and select 'Apps and Features'.右键单击 Windows 按钮并选择“应用程序和功能”。
  2. Select Programs and Features on the right under related settings.在相关设置下选择右侧的程序和功能。
  3. Select Turn Windows Features on or off.选择打开或关闭 Windows 功能。 Select Hyper-V and click OK.选择 Hyper-V,然后单击确定。

The FIX IS SIMPLE ...修复很简单......

If you are using Docker Desktop for Windows, go to the System Tray in the lower right corner of your Windows screen, right-click the docker whale icon , and in the Docker settings popup choose Switch to Windows containers ...如果你使用的是Docker桌面887414387988,go到你的Windows屏幕右下角的系统托盘,右击docker鲸鱼图标,在Docker设置弹出容器88374中选择88374切换到18874

在此处输入图像描述

You cannot use the Linux Containers unless you install and are running a Linux Container host VM like Moby VM running under HyperVisor and also install and run the Docker Daemons and all its dependencies.您不能使用 Linux 容器,除非您安装并运行 Linux 容器主机 VM,例如在 HyperVisor 下运行的 Moby VM,并且还安装并运行 Docker 守护进程及其所有依赖项。

I would just use Windows Containers.我只会使用 Windows 容器。 Otherwise, you are looking at a larger setup on your Windows computer.否则,您将在 Windows 计算机上查看更大的设置。

Updating my Windows version seems to fix this problem.更新我的 Windows 版本似乎可以解决这个问题。 I had the same error, but after updating Windows, Docker is working like a charm.我遇到了同样的错误,但是在更新 Windows 之后,Docker 的工作就像一个魅力。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM