Win10 系統
Docker Desktop 是 Docker 在 Windows 10 和 macOS 操作系統上的官方安裝方式,這個方法依然屬於先在虛擬機中安裝 Linux 然后再安裝 Docker 的方法。
Docker Desktop 官方下載地址: https://hub.docker.com/editions/community/docker-ce-desktop-windows
注意:此方法僅適用於 Windows 10 操作系統專業版、企業版、教育版和部分家庭版!
安裝 Hyper-V
Hyper-V 是微軟開發的虛擬機,類似於 VMWare 或 VirtualBox,僅適用於 Windows 10。這是 Docker Desktop for Windows 所使用的虛擬機。
但是,這個虛擬機一旦啟用,QEMU、VirtualBox 或 VMWare Workstation 15 及以下版本將無法使用!如果你必須在電腦上使用其他虛擬機(例如開發 Android 應用必須使用的模擬器),請不要使用 Hyper-V!
安裝流程:
也可以通過命令來啟用 Hyper-V ,請右鍵開始菜單並以管理員身份運行 PowerShell,執行以下命令:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All
有的童鞋可能會遇到沒有hyper -v的開啟選項
win10沒有Hyper-v的解決方法 將以下代碼復制到文本中 並將文檔重命名Hyper.cmd 用管理員身份運行該文檔
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
然后輸入Y重啟就好啦
安裝之后,可以打開 PowerShell 並運行以下命令檢測是否運行成功:
docker run hello-world
正常就是這樣子啦!
那有的可能會遇到報錯:
error during connect: This error may indicate that the docker daemon is not running.: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.24/containers/json: open //./pipe/docker_engine: The system cannot find the file specified.
那可能是用的wsl2版本太老 那更新一下,下載地址是:
https://docs.microsoft.com/zh-cn/windows/wsl/install-win10#step-4---download-the-linux-kernel-update-package
完了之后有部分還有可能會:docker: error during connect: This error may indicate that the docker daemon。。。那我們在終端執行
1.cd "C:\Program Files\Docker\Docker"
2.DockerCli.exe -SwitchDaemon
默認使用的是Linux Containers,使用這個命令后改為Windows Containers
然后就好啦~~~
參考:https://www.runoob.com/docker/windows-docker-install.html
https://www.cnblogs.com/simadongyang/p/14371850.html