https://is.gd/JjgLXs
首先win10 要是2004以上 19041build以上
請去windows update 更新win10 2004
安裝有linux kernel的WSL2
https://docs.microsoft.com/en-us/windows/wsl/install-win10
Powershell 以系統管理員執行
打開WSL功能
$ dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linu
打開virtualmachine platform功能
$ dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /nor
或者透過控制台打開
https://i.imgur.com/qEcPPCq.png
重開機
下載WSL2 linux kernel 安裝
https://aka.ms/wsl2kernel
https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
直接點擊wsl_update_x64.msi安裝
powershell 將WSL預設版本調成WSL2
$ wsl --set-default-version 2
點開microsoft store安裝 你要的WSL版本 https://aka.ms/wslstore
https://docs.microsoft.com/en-us/windows/wsl/media/store.png

設帳號密碼
https://docs.microsoft.com/en-us/windows/wsl/media/ubuntuinstall.png

再來就可以用WSL2了
C槽會mount在 WSL的路徑
/mnt/c
所以檔案系統是互通的
-------------------------------------
安裝win10 docker desktop
https://docs.docker.com/docker-for-windows/wsl/
一定要安裝最新版
https://download.docker.com/win/stable/Docker%20Desktop%20Installer.exe
安裝時勾選WSL2 Intergration 就不需要開啟hyperV就能用
win10家用版也可使用
安裝完點開Docker Desktop 設定確認一下 WSL2功能開啟
https://docs.docker.com/docker-for-windows/images/wsl2-enable.png


打開WSL2的terminal (WSL2不需要另外安裝linux版docker-ce)
$ docker version
$ docker pull hello-world
再來就可以開始使用WSL2 linux kernel的docker
再也不需要用win10 hyperV docker
然後目前vscode有支援WSL開發
https://code.visualstudio.com/blogs/2020/03/02/docker-in-wsl2
記得裝外掛
https://is.gd/pk0DaX
win10可以很方便使用linux開發了
不需要用vm
--
All Comments