下载和配置Docker·Desktop
Docker官网下载 https://www.docker.com/products/docker-desktop/
或者
通过网盘分享的文件:Docker
链接: https://pan.baidu.com/s/1QEpUaaSOBMAB4szvsIKNMg?pwd=73q3 提取码: 73q3
声明 (一切与Docker有关的,用管理员身份运行,包括powershell)
一、启动Windows功能
方法1
方法2
下载上面的网盘链接里的这两个文件,或者自己创建这两个文件。
enable_hyper_v.cmd 文件的作用相当于上面图片里的 启动Windows功能的Hyper-V全部勾选
其文件内容如下:
pushd "%~dp0"
dir /b %SystemRoot%servicingPackages*Hyper-v*.mum >hyper-v.txt
for /f %%i in ('findstr /i . hyper-v.txt 2^>nul') do dism /online /norestart
/add-package:"%SystemRoot%servicingPackages%%i"
del hyper-v.txt
Dism /online /enable-feature /featurename:Microsoft-Hyper-V-All /LimitAccess /ALL
鼠标右键点击 enable_hyper_v.cmd 选择以管理员身份运行
containers.bat 文件也是一样,需要以管理员身份运行,这个后面再讲
二、下载好Docker·Desktop 需要设置
1.软件中文化
上面网盘链接里的 DockerDesktop-CN-master.zip 下载下来,并解压
在解压好的文件夹里 找到相对应的版本
汉化 不要在docker运行的时候弄

2.启动 Docker 点击设置
不仅要允许Docker·Desktop过防火墙,并且不能开火绒、360等软件、还要关闭可能占用 hosts
文件的程序(如文本编辑器、杀毒软件、VPN 工具等)
-
下载 Process Explorer → 搜索
hosts
→ 结束相关进程。
C:WindowsSystem32
wslhost.exe
vmcompute.exe
这里我只是截图重要部分,作为例子,不懂的话,看上面这张图deepseek的分析
路径直接复制进去deepseek提到的路径:
C:Program FilesDockerDocker esourcescom.docker.backend.exe
C:WindowsSystem32lxsswslhost.exe
C:WindowsSystem32mcompute.exe
注意!wslhost.exe放在哪里路径就是哪里
后面就不演示了,我相信你们都看的懂deepseek说的
入站规则、出站规则都要新建规则
#powershell 管理员身份运行
wsl --shutdown
Start-Process "C:Program FilesDockerDockerDocker Desktop.exe"
# powershell 管理员运行
# 开启docker服务
net start com.docker.service
# 更新wsl
wsl --update
# 设置 WSL2 为默认版本
wsl --set-default-version 2
# 启用 Hyper-V
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-All
cd "C:Program FilesDockerDocker"
# 启动docker daemon
.DockerCli.exe -SwitchDaemon
{
"features": {
"buildkit": true
},
"builder": {
"gc": {
"defaultKeepStorage": "20GB",
"enabled": true
}
},
"experimental": true,
"registry-mirrors": [
"https://docker.mirrors.ustc.edu.cn",
"http://hub-mirror.c.163.com",
"https://registry.docker-cn.com"
]
}
四、我遇到的一些问题 如何解决
这个问题是windows containers 功能没有开启,解决办法:创建一个 containers.bat 文件,内容如下:
或者下载文章开头那个网盘里的containers.bat
鼠标右键点击 containers.bat 以管理员身份打开
pushd "%~dp0"
dir /b %SystemRoot%servicingPackages*containers*.mum >containers.txt
for /f %%i in ('findstr /i . containers.txt 2^>nul') do dism /online /norestart /add-package:"%SystemRoot%servicingPackages%%i"
del containers.txt
Dism /online /enable-feature /featurename:Containers -All /LimitAccess /ALL
pause
这个报错忘记截图了,但是我有复制报错——>
An unexpected error occurred Docker Desktop encountered an unexpected error and needs to close. Search our troubleshooting documentation to find a solution or workaround. Alternatively, you can gather a diagnostics report and submit a support request or GitHub issue. running engine: waiting for the VM setup to be ready: updating hosts: status code not OK but 500: Unhandled exception: 对路径“C:WINDOWSSystem32driversetchosts”的访问被拒绝。
解决方法:
右键点击 Docker Desktop 快捷方式 → 选择 以管理员身份运行。
原因:修改
hosts
文件需要管理员权限。手动修改 hosts 文件 (打开路径
C:WindowsSystem32driversetc
)
右键点击
hosts
文件 → 属性 → 安全 选项卡。选择当前用户 → 点击 编辑 → 勾选 完全控制 → 点击 应用。
重启 Docker Desktop。
查看文件占用或锁定
关闭可能占用
hosts
文件的程序(如文本编辑器、杀毒软件、VPN 工具等)。使用工具解锁:
下载 Process Explorer → 搜索
hosts
→ 结束相关进程。- 重置 hosts 文件属性
右键点击
hosts
→ 属性 → 取消勾选 只读(如果已勾选)
五、记录(也称备份)
你就按照我这样的,配置好docker,以后有什么报错,首先想到是不是windows需要更新了、或者是什么杀毒软件在后台了、或者是端口被占用了。如果是windows需要更新,win+i键
2、记录
这里我放各种文件的路径和文件的内容,我怕哪个设置错了,我又要重装docker 这很麻烦。
我装了Ubuntu-24.04版本,所以设置里是Ubuntu-24.04,你们装了什么版本的子系统 {打开cmd输入 wsl -l -v 就可以看到}
settings-store.json文件
C:Users95AppDataRoamingDocker |
{
"AutoPauseTimeoutSeconds": 600,
"AutoStart": true,
"DesktopTerminalEnabled": true,
"DisplayedOnboarding": true,
"EnableDockerAI": false,
"IntegratedWslDistros": [
"Ubuntu-24.04"
],
"LicenseTermsVersion": 2,
"SettingsVersion": 41,
"UseContainerdSnapshotter": true
}
hosts文件
C:WindowsSystem32driversetc |
## Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# Localhost (IPv4)
127.0.0.1 localhost
# Localhost (IPv6)
::1 localhost
# Added by Docker Desktop
127.0.0.1 host.docker.internal
127.0.0.1 gateway.docker.internal
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
# End of section
# GitHub 域名解析
185.199.108.133 raw.githubusercontent.com
140.82.113.4 github.com
daemon.json文件
C:ProgramDataDockerconfig |
{
"builder": {
"gc": {
"defaultKeepStorage": "20GB",
"enabled": true
}
},
"dns": [
"8.8.8.8",
"114.114.114.114"
],
"experimental": true,
"features": {
"buildkit": true
},
"ipv6": false,
"registry-mirrors": [
"https://docker.mirrors.ustc.edu.cn",
"http://hub-mirror.c.163.com",
"https://registry.docker-cn.com",
"https://mirror.ccs.tencentyun.com"
]
}