简体   繁体   English

Docker 未从 Windows 11 开始使用 WSL 2

[英]Docker not starting on Windows 11 with WSL 2

I'm trying to setup docker with WSL 2 to run a Dockerfile. I downloaded Docker Desktop, and when I tried to follow the quick start guide, I got the following error:我正在尝试使用 WSL 2 设置 docker 以运行 Dockerfile。我下载了 Docker Desktop,当我尝试按照快速入门指南操作时,出现以下错误:

docker: error during connect: This error may indicate that the docker daemon is not running.: Post "http://%2F%2F.%2Fpipe%d2Fdocker_engine/v1.24/containers/create?name=repo": open //./pipe/docker_enginer: The system cannot find the file specified.

I set com.docker.service to run in the Task Manager, and have run:我将 com.docker.service 设置为在任务管理器中运行,并运行:

“c:\Program Files\Docker\Docker\DockerCli.exe” -SwitchDaemon

I have also quit Docker Desktop and reopened it in admin mode, and I still get the message that Docker Desktop has stopped.我也退出了 Docker Desktop 并在管理员模式下重新打开它,但我仍然收到 Docker Desktop 已停止的消息。

Please let me know if there's any other options, thanks!如果有其他选择,请告诉我,谢谢!

I managed to solve the problem in this way:我设法以这种方式解决了这个问题:

  1. delete config file AppData/Roaming/Docker/settings.json删除配置文件AppData/Roaming/Docker/settings.json
  2. start Docker Desktop (it will create new default settings.json)启动 Docker Desktop(它将创建新的默认 settings.json)

You need to re-configure settings, so it is also good idea to save the old settings.json and compare settings with the new one.您需要重新配置设置,因此最好保存旧的 settings.json 并将设置与新设置进行比较。

latest version 4.5.0 It won't work for me too, for me downgrade to 4.4.4 it worked.最新版本 4.5.0 它对我也不起作用,对我来说降级到 4.4.4 它起作用了。 It may be problem with the latest version最新版本可能有问题

for released note and older version Here对于已发布的注释和旧版本这里

Note: You can install an older version and update to latest version 4.5.0注意:您可以安装旧版本并更新到最新版本 4.5.0

Wow!哇! I spent multiple days trying to get Docker for windows 11 to work.我花了几天时间试图让 Docker for windows 11 工作。 What finally did it was downgrading to version 4.4.4 as @GinglrBell recommended.正如@GinglrBell 推荐的那样,它最终降级到了 4.4.4 版。 Here's a link Docker version 4.4.4 .这是Docker 版本 4.4.4的链接。

Make sure WSL is installed and virtualization is enabled.确保已安装 WSL 并启用了虚拟化。 If you try to open WSL and you get an error telling you to enable virtualization in BIOS, run this command as Admin in powershell: bcdedit /set hypervisorlaunchtype auto ( Docker src ).如果您尝试打开 WSL 并收到一条错误消息,告诉您在 BIOS 中启用虚拟化,请在 powershell 中以管理员身份运行此命令: bcdedit /set hypervisorlaunchtype auto ( Docker src )。 Then restart your PC.然后重新启动你的电脑。

If you are running Docker Desktop for Windows 4.5.0 then you should be aware of an existing issue where the default backend selected after installing is not the correct one.如果您正在运行 Docker Desktop for Windows 4.5.0,那么您应该注意一个存在的问题,即安装后选择的默认后端不正确。

You can switch to the correct backend manually by editing the file located at: %APPDATA%\Docker\settings.json (sometimes is %APPDATA%\Roaming\Docker\settings.json ) and at the bottom of the file change the value for the wslEngineEnabled field to true .您可以通过编辑位于以下位置的文件手动切换到正确的后端: %APPDATA%\Docker\settings.json (有时是%APPDATA%\Roaming\Docker\settings.json )并在文件底部更改wslEngineEnabled字段为true After that Docker Desktop should start correctly.之后 Docker Desktop 应该可以正确启动。

Similar issue and solution is mentioned here by the user mccaa25 .用户mccaa25在这里提到了类似的问题和解决方案。

Manged to switch to Windows Containers.设法切换到 Windows 容器。 (Docker v4.9.0) (Docker v4.9.0)

What I did was to change the following in the settings.json: "useWindowsContainers": true, "wslEngineEnabled": true,我所做的是在 settings.json 中更改以下内容:“useWindowsContainers”:true,“wslEngineEnabled”:true,

Also set security on folder:还要在文件夹上设置安全性:

C:\ProgramData\Docker (I set "Everyone" full control.) C:\ProgramData\Docker(我设置“所有人”完全控制。)

After that I used the "Switch to Windows Containers"-feature from the task-bar icon content menu之后,我使用了任务栏图标内容菜单中的“切换到 Windows 容器”功能

I hit this issue today, and the steps below are what worked for me - the gist is that I needed to install WSL 2 beforehand.我今天遇到了这个问题,下面的步骤对我有用 - 要点是我需要事先安装 WSL 2。 Most of my steps were derived from here :我的大部分步骤都来自这里

  1. open powershell as admin以管理员身份打开 powershell
  2. wsl -l -v # Windows Subsystem for Linux has no installed distributions wsl -l -v # Linux 的 Windows 子系统没有安装的发行版
  3. install linux kernel update from here # in my case, x64-based这里安装 linux kernel 更新 # 在我的例子中,基于 x64
  4. wsl --set-default-version 2 wsl --set-default-version 2
  5. wsl --list --online # shows several linux distributions, I picked a recent one wsl --list --online # 显示几个 linux 发行版,我选择了最近的一个
  6. wsl --install -d Ubuntu-20.04 # then create default linux user name and password wsl --install -d Ubuntu-20.04 # 然后创建默认的linux用户名和密码
  7. install windows docker desktop from here # now starts successfully这里安装 windows docker 桌面#现在启动成功

I tried Janne Rantala's method.我尝试了 Janne Rantala 的方法。

But the same problem occurs again after several days.但是几天后再次出现同样的问题。

My final solution is to uninstall Docker Desktop, then download and run the installation file as an administrator.我最终的解决方案是卸载 Docker Desktop,然后下载并以管理员身份运行安装文件

Then the problem no longer appears again.然后问题不再出现。

I have been having some Docker setting up troubles for a fair amount of time.我已经有一些 Docker 设置麻烦了相当长的时间。 I think I had to just make sure I removed all references of Docker. After buying Windows 10 pro I still had issues, I did have to look into the following folders:我想我必须确保我删除了 Docker 的所有引用。购买 Windows 10 pro 后我仍然遇到问题,我确实必须查看以下文件夹:

C:\Users\%UserName%\AppData\Local\Temp\Docker
C:\Users\%UserName%\AppData\Roaming\Docker

I also deleted the Docker file in my programfiles folder我还删除了 programfiles 文件夹中的 Docker 文件

Navigated to said file and deleted Docker files.导航到所述文件并删除了 Docker 个文件。 Used the docker installer, checkboxes (to use wsl2).使用 docker 安装程序,复选框(使用 wsl2)。

I was able to resolve this issue on my machine by installing the Linux kernel update package as described in the Microsoft guide我能够通过安装 Linux kernel 更新 package 在我的机器上解决这个问题,如Microsoft 指南中所述

I was faicing the same issue and resolved.我遇到了同样的问题并解决了。 I have just open Microsoft Store application and after that opened the docker and its working fine.我刚刚打开Microsoft Store应用程序,然后打开 docker 并且它工作正常。 This is wired but sharing this so it might helps someone.这是有线的,但分享这个,所以它可能会对某人有所帮助。

I solved this issue by enabling the windows feature "Windows Hypervisor Platform" and restarting my computer.我通过启用 windows 功能“Windows Hypervisor Platform”并重新启动计算机解决了这个问题。

I installed Docker Desktop v4.16.2我安装了 Docker Desktop v4.16.2

不要创建桌面图标,安装 docker 时跳过桌面图标选项。

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

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