【云原生】Docker安装,告别报错

【云原生】Docker安装,告别报错_第1张图片
Docker学习笔记,请参考:笔记


这里讲解window安装docker,小航的电脑:Win11家庭版,不自带 Hyper-V

1.安装 Hyper-V

复制脚本txt,然后重新命名为bat,右键使用管理员执行

pushd "%~dp0"
dir /b %SystemRoot%\servicing\Packages\*Hyper-V*.mum >hyper-v.txt
for /f %%i in ('findstr /i . hyper-v.txt 2^>nul') do dism /online /norestart /add-package:"%SystemRoot%\servicing\Packages\%%i"
del hyper-v.txt
Dism /online /enable-feature /featurename:Microsoft-Hyper-V-All /LimitAccess /ALL

2.初始化环境
管理员身份打开PowerShell:分别执行以下命令

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart


dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

3.更新wsl2

下载安装:地址
管理员身份打开PowerShell:执行以下命令

wsl --set-default-version 2

4.安装Docker
官网

傻瓜式安装 -> waiting

成功安装后就会看到以下界面:

【云原生】Docker安装,告别报错_第2张图片
进去后成功的界面:
【云原生】Docker安装,告别报错_第3张图片
【云原生】Docker安装,告别报错_第4张图片

可能会遇到的一系列问题:

docker 打开报错 System.InvalidOperationException: Failed to set version to docker-desktop: exit code: -1

【云原生】Docker安装,告别报错_第5张图片
解决方案:

管理员身份打开PowerShell:执行以下命令,重启电脑即可

netsh winsock reset

配置镜像加速:
【云原生】Docker安装,告别报错_第6张图片
小航这里习惯用命令行的界面了,所以使用管理员打开命令行:

docker info

Registry Mirrors:                                                                                                        			https://xxxxxx.mirror.aliyuncs.com/

测试是否安装成功:

docker run hello

C:\WINDOWS\system32>docker run hello-world                                                                              Unable to find image 'hello-world:latest' locally                                                                       latest: Pulling from library/hello-world                                                                                2db29710123e: Pull complete                                                                                             Digest: sha256:2498fce14358aa50ead0cc6c19990fc6ff866ce72aeb5546e1d59caac3d0d60f                                         Status: Downloaded newer image for hello-world:latest                                                                                                                                                                                           Hello from Docker!                                                                                                      This message shows that your installation appears to be working correctly.                                                                                                                                                                      To generate this message, Docker took the following steps:                                                               1. The Docker client contacted the Docker daemon.                                                                       2. The Docker daemon pulled the "hello-world" image from the Docker Hub.                                                   (amd64)                                                                                                              3. The Docker daemon created a new container from that image which runs the                                                executable that produces the output you are currently reading.                                                       4. The Docker daemon streamed that output to the Docker client, which sent it                                              to your terminal.                                                                                                                                                                                                                           To try something more ambitious, you can run an Ubuntu container with:                                                   $ docker run -it ubuntu bash                                                                                                                                                                                                                   Share images, automate workflows, and more with a free Docker ID:                                                        https://hub.docker.com/                                                                                                                                                                                                                        For more examples and ideas, visit:                                                                                      https://docs.docker.com/get-started/                                                                                                                              

你可能感兴趣的:(Docker,docker,云原生,容器)